:root {
  --bg: #f6f7f9; --panel: #ffffff; --fg: #1d2330; --muted: #6b7280; --line: #e3e6eb;
  --accent: #2f6fde; --ok: #1a8a4a; --warn: #b7791f; --bad: #c53030;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--fg); background: var(--bg);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14171c; --panel: #1c2027; --fg: #e6e8eb; --muted: #9aa3ad; --line: #2c323b; --accent: #6b9cff; --ok: #4cc27f; --warn: #e0a84a; --bad: #f07171; }
}
[x-cloak] { display: none !important; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); }
h1, h2, h3 { margin: 0 0 12px; font-weight: 600; }
a { color: var(--accent); text-decoration: none; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
pre { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 10px; white-space: pre-wrap; word-break: break-all; }

.layout { display: flex; min-height: 100vh; }
nav { width: 180px; flex: none; background: var(--panel); border-right: 1px solid var(--line); padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
nav .brand { font-size: 17px; margin-bottom: 12px; }
nav a { color: var(--fg); padding: 6px 10px; border-radius: 6px; }
nav a.active { background: var(--accent); color: #fff; }
nav .plain { margin-top: auto; }
main { flex: 1; padding: 20px 24px; min-width: 0; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px; }
.login { display: grid; place-items: center; min-height: 100vh; }
.login .card { width: 320px; display: flex; flex-direction: column; gap: 12px; }

label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; }
label.check { flex-direction: row; align-items: center; gap: 6px; padding-top: 22px; }
input, select { font: inherit; color: var(--fg); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
input:not([type=checkbox]), select { min-width: 0; }
fieldset { min-width: 0; border: 1px solid var(--line); border-radius: 8px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 8px 12px 12px; }
legend { color: var(--muted); font-size: 12px; padding: 0 4px; }
button { font: inherit; cursor: pointer; color: var(--fg); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; }
button:hover { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--bad); }
button.plain { border: none; background: none; color: var(--muted); }

.bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.bar h2 { margin: 0; }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 500; color: var(--muted); font-size: 12px; white-space: nowrap; }
td.actions { white-space: nowrap; text-align: right; }
td.actions button { margin-left: 4px; }

.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px; border: 1px solid currentColor; }
.ok { color: var(--ok); } .warn { color: var(--warn); } .bad { color: var(--bad); }
.error { color: var(--bad); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.banner { padding: 8px 12px; border-radius: 6px; border: 1px solid currentColor; cursor: pointer; }
.notice { color: var(--ok); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.tile span { color: var(--muted); font-size: 12px; }
.tile b { font-size: 22px; font-weight: 600; }
.alerts { padding-left: 18px; }

.filters { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
td.ifaces { font-size: 12px; overflow-wrap: anywhere; min-width: 140px; }
.chart { overflow: hidden; display: flex; align-items: flex-end; gap: 1px; height: 140px; padding: 8px; margin-bottom: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.chart .col { flex: 1 1 0; min-width: 0; height: 100%; display: flex; align-items: flex-end; }
.chart .fill { width: 100%; background: var(--accent); border-radius: 2px 2px 0 0; }

.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: grid; place-items: center; padding: 16px; z-index: 10; }
.modal .card { width: min(480px, 100%); max-height: 90vh; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.modal .card.wide { width: min(760px, 100%); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.path { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.path p { flex-basis: 100%; margin: 0; }
.buttons { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 720px) {
  .layout { flex-direction: column; }
  nav { width: auto; flex-direction: row; flex-wrap: wrap; border-right: none; border-bottom: 1px solid var(--line); }
  nav .plain { margin-top: 0; margin-left: auto; }
  main { padding: 16px; }
  fieldset { grid-template-columns: 1fr; }
}
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs button { border: none; background: none; padding: 6px 12px; border-bottom: 2px solid transparent; border-radius: 0; }
.tabs button.active { border-bottom-color: var(--accent); font-weight: 600; }
.sysrow { grid-template-columns: minmax(0, 2fr) minmax(0, 2fr) auto; align-items: center; }
.sysrow small { grid-column: 1 / -1; }
.muted.badge { color: var(--muted); }
fieldset > .sysrow, fieldset > .grid { grid-column: 1 / -1; }
.badge { white-space: nowrap; }
fieldset label.check { padding-top: 0; }
pre.logs { max-height: 360px; overflow: auto; font-size: 12px; white-space: pre-wrap; }
pre.logs div { padding: 1px 0; }
.diag-result { margin-top: 8px; }
.alerts small { margin-left: 8px; }
