:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #16181d;
  --muted: #5f6673;
  --line: #e2e5ea;
  --accent: #1f6feb;
  --accent-text: #ffffff;
  --ok: #1a7f37;
  --ok-bg: #e6f4ea;
  --bad: #b42318;
  --bad-bg: #fdecea;
  --notice: #fff7e0;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #171a21;
    --text: #e7e9ee;
    --muted: #9aa3b2;
    --line: #2a2f3a;
    --accent: #4c8dff;
    --accent-text: #0b0d12;
    --ok: #57c77b;
    --ok-bg: #16301f;
    --bad: #ff7a6b;
    --bad-bg: #3a1714;
    --notice: #2d2612;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
  flex-wrap: wrap;
}

.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.brand span { color: var(--muted); font-weight: 400; }
nav { display: flex; gap: 14px; flex: 1; flex-wrap: wrap; }
nav a { color: var(--text); text-decoration: none; }
nav a:hover { color: var(--accent); }

.notice {
  padding: 8px 16px;
  background: var(--notice);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

main { max-width: 1040px; margin: 0 auto; padding: 16px; }

footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  max-width: 1040px;
  margin: 24px auto;
  padding: 0 16px;
  color: var(--muted);
  font-size: 13px;
  flex-wrap: wrap;
}

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

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
  min-width: 0;
}

.card.narrow { max-width: 640px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

h2, h3, h4 { margin: 0 0 10px; line-height: 1.25; }
h3 a { text-decoration: none; }

.kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--line);
  flex-wrap: wrap;
}
.kv > span:first-child { color: var(--muted); }
.kv > span:last-child { text-align: right; overflow-wrap: anywhere; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 500;
  vertical-align: middle;
}
.badge.ok { color: var(--ok); background: var(--ok-bg); border-color: transparent; }
.badge.bad { color: var(--bad); background: var(--bad-bg); border-color: transparent; }

button, .button {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
button.secondary { background: transparent; color: var(--accent); }
button.small { padding: 3px 10px; font-size: 13px; }
button:disabled { opacity: 0.55; cursor: progress; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0; }

input, select {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  min-width: 0;
}

form label { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin: 6px 0; }
form label input { width: 140px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 12px; padding: 10px 12px; }
legend { color: var(--muted); padding: 0 4px; }
.checks { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
label.check { display: inline-flex; gap: 6px; align-items: center; justify-content: flex-start; }
label.check input { width: auto; }

.ticket { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ticket input { width: 120px; }

.result { margin-left: 8px; font-size: 13px; }
.result.ok { color: var(--ok); }
.result.err { color: var(--bad); }
.result.busy { color: var(--muted); }

pre.out {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  max-height: 240px;
  overflow: auto;
  font-size: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
pre.out:empty { display: none; }

.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }

dialog {
  max-width: 480px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  padding: 20px;
}
dialog::backdrop { background: rgb(0 0 0 / 0.45); }

code { font-family: var(--mono); font-size: 13px; }

@media (max-width: 560px) {
  form label { flex-direction: column; align-items: stretch; }
  form label input { width: 100%; }
  .ticket input { width: 100%; }
}
