:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #5d6878;
  --line: #dfe3ea;
  --accent: #1f5eff;
  --accent-text: #ffffff;
  --ok-bg: #e5f6ec; --ok: #136c3a;
  --off-bg: #eef0f3; --off: #59626f;
  --warn-bg: #fff3dc; --warn: #8a5a00;
  --error-bg: #fde8e8; --error: #a11d1d;
  --danger: #c62828;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c; --surface: #1b2129; --text: #e7ebf0; --muted: #9aa5b4; --line: #2c3440;
    --accent: #5b8cff; --ok-bg: #163824; --ok: #7fdca2; --off-bg: #262d36; --off: #a8b1bd;
    --warn-bg: #3a2c0c; --warn: #f3c56b; --error-bg: #3d1717; --error: #ff9b9b; --danger: #ff6b6b;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
code, .mono, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; }
h1 { font-size: 1.5rem; margin: 0.2rem 0 0.8rem; display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
h2 { font-size: 1.1rem; margin: 0 0 0.6rem; }
main { max-width: 1080px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: 0.7rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.top nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.top nav a { color: var(--muted); text-decoration: none; }
.top nav a[aria-current="page"] { color: var(--text); font-weight: 600; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem; margin: 1rem 0;
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.card.highlight { border-color: var(--accent); }
.login { max-width: 420px; margin: 12vh auto 0; }
.confirm { max-width: 640px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.crumbs { color: var(--muted); margin: 0; font-size: 0.9rem; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.card .table-wrap { border: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
pre.config { margin: 0; white-space: pre-wrap; max-height: 8rem; overflow: auto; }
pre.secret {
  padding: 0.8rem; background: var(--bg); border: 1px dashed var(--accent); border-radius: 8px;
  white-space: pre-wrap; word-break: break-all; user-select: all;
}

.badge {
  display: inline-block; padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600;
  background: var(--off-bg); color: var(--off); white-space: nowrap;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.off { background: var(--off-bg); color: var(--off); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }

.flash { padding: 0.7rem 0.9rem; border-radius: 8px; margin: 0 0 1rem; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--error-bg); color: var(--error); }

form.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0.9rem 1rem; }
form.grid .wide, form.grid .actions { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 0.3rem; font-weight: 600; font-size: 0.9rem; }
label small { font-weight: 400; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 0.5rem; font-weight: 500; }
input, textarea {
  width: 100%; padding: 0.55rem 0.65rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; font-weight: 400;
}
input[type="checkbox"] { width: auto; }
input:disabled { opacity: 0.7; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { resize: vertical; }

.actions { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
button, .button {
  display: inline-block; padding: 0.5rem 0.9rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.small { padding: 0.25rem 0.6rem; font-size: 0.85rem; }
button.link { border: 0; background: none; padding: 0; color: var(--muted); font-weight: 400; }
.danger-link { color: var(--danger); }
form.inline { display: inline; }
form.stacked { display: grid; gap: 0.6rem; }
form.stacked button { justify-self: start; margin-top: 0.3rem; }
.inline-form { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.inline-form input { width: 9.5rem; }

@media (max-width: 600px) {
  main { padding: 1rem 0.75rem 2rem; }
  th, td { padding: 0.5rem; }
}

/* On narrow screens each row becomes a labelled card, so no column (or action) hides off to the right. */
@media (max-width: 720px) {
  table.stack thead { display: none; }
  table.stack tr { display: block; padding: 0.5rem 0; border-bottom: 1px solid var(--line); }
  table.stack tbody tr:last-child { border-bottom: 0; }
  table.stack td { display: flex; gap: 0.75rem; align-items: baseline; border: 0; padding: 0.3rem 0.75rem; }
  table.stack td::before {
    content: attr(data-label); flex: 0 0 6.5rem; color: var(--muted);
    font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em;
  }
  table.stack td[colspan]::before { display: none; }
  table.stack td > * { min-width: 0; }
  table.stack .inline-form { flex: 1; }
  table.stack .inline-form input { flex: 1; width: auto; min-width: 8rem; }
}
