:root {
  --bg: #eef2f7;
  --panel: #fff;
  --ink: #152033;
  --muted: #5b677d;
  --line: #d5dce8;
  --accent: #1f5fd6;
  --ok: #1b7f4a;
  --warn: #9a6b00;
  --err: #b42318;
  --ok-bg: #e8f7ee;
  --warn-bg: #fff6df;
  --err-bg: #fdecea;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.45 system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #dfe7f4, var(--bg) 220px);
  padding: 1rem clamp(.8rem, 2vw, 1.5rem) 3rem;
}
h1,h2,h3 { margin: 0 0 .4rem; }
.sub { margin: 0; color: var(--muted); font-size: .92rem; }
a { color: var(--accent); }
.top, .diag-head, .row {
  display: flex; gap: .6rem; align-items: center;
  justify-content: space-between; flex-wrap: wrap;
}
.top { margin-bottom: 1rem; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
  margin-bottom: .9rem;
  box-shadow: 0 8px 24px rgba(24,32,51,.04);
}
.hidden { display: none !important; }
.grid-3 {
  display: grid; gap: .65rem; margin: .6rem 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
@media (max-width: 900px) {
  .grid-3 { grid-template-columns: 1fr; }
}
label { display: flex; flex-direction: column; gap: .25rem; font-size: .82rem; color: var(--muted); font-weight: 600; }
.inline { flex-direction: row; align-items: center; gap: .4rem; font-weight: 500; }
.checks { gap: .4rem; }
input, select {
  font: inherit; color: var(--ink); border: 1px solid var(--line);
  border-radius: 10px; padding: .5rem .65rem; background: #fff;
}
.btn {
  border: 1px solid var(--line); background: #f7f9fd; color: var(--ink);
  border-radius: 10px; padding: .45rem .75rem; font: inherit; font-weight: 650; cursor: pointer;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger { background: var(--err); border-color: var(--err); color: #fff; }
.badge {
  display: inline-flex; align-items: center; border-radius: 999px;
  padding: .18rem .55rem; font-size: .75rem; font-weight: 750;
}
.badge-off { background: #eceff5; color: var(--muted); }
.badge-on, .badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-error { background: var(--err-bg); color: var(--err); }
.badge-unknown { background: #eceff5; color: var(--muted); }
.meta { color: var(--muted); font-size: .88rem; }
.table-wrap { overflow: auto; margin-top: .6rem; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th, td { text-align: left; padding: .45rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .02em; }
.form-box { margin-top: .7rem; padding: .75rem; border: 1px dashed var(--line); border-radius: 12px; background: #fafbfe; }
.codeblock {
  background: #0f1728; color: #d7e0f2; border-radius: 12px; padding: .8rem;
  overflow: auto; font-size: .78rem; line-height: 1.4; max-height: 240px;
}
.log-view { max-height: 220px; white-space: pre-wrap; margin-top: 1rem; }
.settings-grid {
  display: grid; gap: .55rem;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  margin-top: .6rem;
}
.settings-grid label input { width: 100%; }
.st-h3 { margin: 1rem 0 .4rem; font-size: 1rem; }
.pill {
  display: inline-block; margin: .1rem .15rem .1rem 0; padding: .1rem .35rem;
  border-radius: 6px; background: #eef3ff; font-size: .75rem;
}
.pill.warn { background: var(--warn-bg); }
.pill.ok { background: var(--ok-bg); }

.settings-group {
  border: 1px solid var(--line, #d5ddd9);
  border-radius: 14px;
  padding: 0.75rem 1rem 1rem;
  margin: 0 0 1rem;
  background: rgba(255,255,255,0.55);
}
.settings-group legend {
  font-weight: 700;
  padding: 0 0.4rem;
  color: var(--teal, #0b3d3a);
}
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem 1rem;
}

.setting {
  display: flex; flex-direction: column; gap: 0.35rem;
  font-size: 0.86rem;
  padding: 0.65rem 0.7rem;
  border-radius: 12px;
  background: rgba(255,255,255,0.65);
  border: 1px solid rgba(18,36,31,0.08);
}
.setting-label { font-weight: 700; color: #0b3d3a; font-size: 0.92rem; }
.setting.bool {
  flex-direction: row;
  align-items: flex-start;
  gap: 0.75rem;
}
.setting.bool .setting-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.switch {
  display: inline-flex; align-items: center; gap: 0.4rem;
  flex: 0 0 auto; margin-top: 0.15rem; cursor: pointer;
}
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui {
  width: 2.4rem; height: 1.35rem; border-radius: 999px;
  background: #c5d0cb; position: relative;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.15);
  transition: background 0.15s ease;
}
.switch-ui::after {
  content: "";
  position: absolute; top: 0.15rem; left: 0.15rem;
  width: 1.05rem; height: 1.05rem; border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: transform 0.15s ease;
}
.switch input:checked + .switch-ui { background: #2f9e68; }
.switch input:checked + .switch-ui::after { transform: translateX(1.05rem); }
.switch-text { font-size: 0.75rem; font-weight: 700; color: #5a6f68; min-width: 1.6rem; }
.setting em { font-style: normal; font-weight: 500; color: #2f9e68; font-size: 0.78rem; }

.setting-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}
.setting-set { margin-left: 0.25rem; }
.info-btn {
  flex: 0 0 auto;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  border: 2px solid #1a5cff;
  background: #e8f0ff;
  color: #1a5cff;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  font-weight: 900;
  font-style: italic;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 2px rgba(26, 92, 255, 0.2);
}
.info-btn:hover,
.info-btn:focus-visible {
  background: #1a5cff;
  color: #fff;
  outline: none;
}
.settings-help-dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  max-width: min(420px, calc(100vw - 2rem));
  width: 100%;
  background: #f7faf8;
  color: #12241f;
  box-shadow: 0 16px 48px rgba(12, 28, 24, 0.28);
}
.settings-help-dialog::backdrop {
  background: rgba(10, 24, 20, 0.45);
}
.settings-help-card {
  padding: 1.1rem 1.15rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.settings-help-card h3 {
  margin: 0;
  font-size: 1.05rem;
  color: #0b3d3a;
  padding-right: 2rem;
}
.settings-help-card section {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.settings-help-card h4 {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #5a6f68;
}
.settings-help-card p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
  color: #1a2e29;
}
.settings-help-close {
  align-self: flex-end;
  margin-top: 0.25rem;
}
.settings-help-x {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  color: #4d635c;
}
.settings-help-dialog .settings-help-card { position: relative; }
.settings-help-x:hover { background: rgba(0,0,0,0.06); color: #0b3d3a; }
