:root {
  --bg: #f6f7f9; --panel: #ffffff; --text: #1d2330; --muted: #667085; --line: #e3e6eb;
  --accent: #1f6feb; --accent-text: #fff; --ok: #1a7f37; --warn: #9a6700; --bad: #cf222e;
  --chip: #eef1f5; --code: #f1f3f6; --shadow: 0 1px 2px rgba(16,24,40,.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218; --panel: #161b22; --text: #e6edf3; --muted: #8d96a0; --line: #2a313c;
    --accent: #4493f8; --accent-text: #0b0e13; --ok: #3fb950; --warn: #d29922; --bad: #f85149;
    --chip: #222a35; --code: #1c222b; --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif; }
a { color: var(--accent); }
.boot { padding: 40px; color: var(--muted); }

.layout { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
nav.side { background: var(--panel); border-right: 1px solid var(--line); padding: 14px 10px; position: sticky; top: 0; height: 100vh; overflow: auto; }
nav.side .brand { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 16px; padding: 4px 8px 14px; }
nav.side .brand img { width: 24px; height: 24px; }
nav.side a { display: block; padding: 7px 10px; border-radius: 7px; color: var(--text); text-decoration: none; margin: 1px 0; }
nav.side a.active, nav.side a:hover { background: var(--chip); }
nav.side .foot { color: var(--muted); font-size: 12px; padding: 14px 10px; }
main { padding: 22px 28px 60px; max-width: 1180px; width: 100%; }
h1 { font-size: 21px; margin: 0 0 16px; font-weight: 650; }
h2 { font-size: 15px; margin: 0 0 10px; font-weight: 650; }
h3 { font-size: 13px; margin: 14px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
p.hint, .hint { color: var(--muted); font-size: 13px; margin: 4px 0 10px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row > input[type=text], .row > input[type=password], .row > input[type=number] { width: auto; flex: 1 1 160px; }
.table-wrap { overflow-x: auto; }
.hidden { display: none !important; }
.spacer { flex: 1; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
td input[type=text], td select { width: 100%; min-width: 90px; }

label.f { display: block; margin: 8px 0; }
label.f > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 3px; }
label.chk { display: inline-flex; gap: 6px; align-items: center; margin: 6px 14px 6px 0; }
.form2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0 16px; }
input, select, textarea, button { font: inherit; color: var(--text); }
input[type=text], input[type=password], input[type=number], input[type=url], select, textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; width: 100%; }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button { background: var(--chip); border: 1px solid var(--line); border-radius: 7px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }
button:hover { filter: brightness(.97); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; font-weight: 600; }
button.danger { color: var(--bad); }
button.small { padding: 3px 8px; font-size: 12.5px; }
button:disabled { opacity: .55; cursor: default; }

.chip { display: inline-block; padding: 1px 8px; border-radius: 99px; background: var(--chip); font-size: 12px; }
.chip.ok { color: var(--ok); } .chip.warn { color: var(--warn); } .chip.bad { color: var(--bad); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 6px; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
pre { background: var(--code); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow: auto; white-space: pre-wrap; word-break: break-all; margin: 6px 0; }
pre.screen { white-space: pre; word-break: normal; max-height: 420px; font-size: 11.5px; line-height: 1.3; }
.copy { position: relative; }
.copy button { position: absolute; top: 6px; right: 6px; }
.muted { color: var(--muted); }
.err { color: var(--bad); }
.okc { color: var(--ok); }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs button.on { background: var(--accent); color: var(--accent-text); }
.state { font-weight: 600; text-transform: capitalize; }
.logs { max-height: 70vh; overflow: auto; }
.logs div { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; padding: 1px 0; white-space: pre-wrap; }
.logs .WARNING { color: var(--warn); } .logs .ERROR { color: var(--bad); }

.auth { max-width: 380px; margin: 9vh auto; }
.auth .card { padding: 24px; }
.auth h1 { display: flex; gap: 10px; align-items: center; }
.auth h1 img { width: 30px; }

#toast { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 10; }
#toast div { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: 9px 14px; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.15); max-width: 420px; }
#toast div.bad { border-left-color: var(--bad); }

.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 12px; z-index: 5; overflow: auto; }
.modal { background: var(--panel); border-radius: 12px; padding: 20px; width: min(720px, 100%); border: 1px solid var(--line); }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  nav.side { position: static; height: auto; display: flex; flex-wrap: wrap; gap: 2px; border-right: 0; border-bottom: 1px solid var(--line); }
  nav.side .brand { width: 100%; padding-bottom: 6px; }
  nav.side .foot { display: none; }
  main { padding: 16px; }
  .hide-sm { display: none; }
}
