:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1f2630;
  --line: #2b3440;
  --text: #e6edf3;
  --muted: #8b98a8;
  --accent: #3fb68b;
  --accent-ink: #06231a;
  --warn: #d9a441;
  --danger: #e5534b;
  --radius: 8px;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); }
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; border-radius: 6px; padding: 8px 14px; background: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.ghost { background: transparent; color: var(--muted); font-weight: 500; }
button.ghost:hover { color: var(--text); background: var(--panel-2); }
button.danger { color: var(--danger); }
button.icon { background: transparent; color: var(--muted); padding: 4px 8px; font-size: 16px; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input, textarea { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; }
textarea { font-family: var(--mono); font-size: 12px; resize: vertical; }
label { display: block; color: var(--muted); font-size: 12px; margin: 10px 0 0; }
label > input, label > textarea { margin-top: 4px; font-size: 14px; color: var(--text); }
label.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0 16px 0 0; font-size: 14px; color: var(--text); }
label.inline input { width: auto; }
fieldset { border: 0; padding: 0; margin: 12px 0 0; }
legend { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
h1, h2 { margin: 0 0 4px; font-weight: 650; }
h1 span, header span { color: var(--accent); }
.muted { color: var(--muted); font-size: 12px; }
.mono { font-family: var(--mono); word-break: break-all; }
.error { color: var(--danger); font-size: 13px; min-height: 1em; }
.row { display: flex; gap: 10px; }
.grow { flex: 1; }
.port { width: 90px; }
.tag { font-size: 10px; padding: 1px 6px; border-radius: 10px; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.tag.warn { color: var(--warn); background: #3a2e14; }

/* login */
#login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.card { width: min(360px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; }
.card button { width: 100%; margin-top: 18px; padding: 10px; }

/* layout */
#app { display: flex; height: 100%; }
#sidebar { width: 290px; flex: none; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
#sidebar header { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; font-size: 15px; }
#search { margin: 0 12px 8px; width: auto; }
#hosts { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
#sidebar footer { border-top: 1px solid var(--line); padding: 8px; display: flex; flex-direction: column; gap: 2px; }
#sidebar footer button { text-align: left; }
.group { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; margin: 14px 8px 4px; }
.host { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border-radius: 6px; background: transparent; color: var(--text); font-weight: 400; text-align: left; }
.host:hover, .host.active { background: var(--panel-2); }
.host .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--line); }
.host .dot.on { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.host .dot.off { background: var(--danger); }
.host .meta { flex: 1; min-width: 0; }
.host .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.host .ip { color: var(--muted); font: 11px var(--mono); }
.host .edit { opacity: 0; padding: 2px 6px; }
.host:hover .edit, .host:focus-within .edit { opacity: 1; }

main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#tabbar { display: flex; align-items: stretch; background: var(--panel); border-bottom: 1px solid var(--line); min-height: 40px; }
#tabs { display: flex; overflow-x: auto; }
.tab { display: flex; align-items: center; gap: 8px; padding: 0 6px 0 14px; border-right: 1px solid var(--line); color: var(--muted); cursor: pointer; white-space: nowrap; font-size: 13px; }
.tab.active { background: var(--bg); color: var(--text); box-shadow: inset 0 2px 0 var(--accent); }
.tab .st { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.tab .st.ok { background: var(--accent); }
.tab .st.dead { background: var(--danger); }
.tab button { padding: 2px 6px; }
#terms { flex: 1; position: relative; min-height: 0; }
.term { position: absolute; inset: 0; padding: 6px 0 0 8px; background: var(--bg); }
#empty { height: 100%; display: grid; place-content: center; text-align: center; padding: 16px; color: var(--muted); }

/* dialogs */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 22px; width: min(480px, calc(100% - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / .6); }
#audit-dialog { width: min(980px, calc(100% - 32px)); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 16px; }
.table-wrap { max-height: 70vh; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; position: sticky; top: 0; background: var(--panel); }
td.mono { font-size: 11px; }

.only-mobile { display: none; }
@media (max-width: 760px) {
  .only-mobile { display: inline-block; }
  #sidebar { position: fixed; inset: 0 auto 0 0; z-index: 10; width: min(300px, 86vw); transform: translateX(-100%); transition: transform .2s; }
  #sidebar.open { transform: none; box-shadow: 0 0 40px rgb(0 0 0 / .6); }
  .host .edit { opacity: 1; }
}
