:root {
  --bg: #f5f6f8; --surface: #fff; --text: #1d2330; --muted: #6b7385;
  --border: #dde1e8; --accent: #0b63ce; --accent-text: #fff;
  --danger-bg: #fdecec; --danger: #a12222; --info-bg: #e8f1fd; --info: #0b4a99;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171d; --surface: #1d222b; --text: #e4e7ee; --muted: #9aa2b3;
    --border: #2e3542; --accent: #4c94ef; --accent-text: #0b0e13;
    --danger-bg: #3a1c1f; --danger: #f19a9a; --info-bg: #182a44; --info: #a9cbf6;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .5rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }
.muted { color: var(--muted); }

.topbar { display: flex; align-items: center; gap: 1.5rem; padding: .75rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { font-weight: 600; color: var(--text); }
.topbar nav { display: flex; gap: 1rem; flex: 1; }
.logout { display: flex; align-items: center; gap: .75rem; margin: 0; }

.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 1.25rem; margin-bottom: 1rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.tile { display: flex; flex-direction: column; gap: .25rem; }
.tile strong { font-size: 2rem; font-variant-numeric: tabular-nums; }
.key { display: block; padding: .75rem; background: var(--bg); border-radius: 6px; word-break: break-all; user-select: all; }

.alert { background: var(--danger-bg); color: var(--danger); padding: .5rem .75rem; border-radius: 6px; margin: 0 0 1rem; }
.alert.info { background: var(--info-bg); color: var(--info); }

label { display: flex; flex-direction: column; gap: .25rem; margin-bottom: 1rem; font-weight: 500; }
input { font: inherit; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button { font: inherit; padding: .55rem 1rem; border: 0; border-radius: 6px; background: var(--accent); color: var(--accent-text); cursor: pointer; font-weight: 600; }
button.link { background: none; color: var(--accent); padding: 0; font-weight: 500; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums; }
.wrap { word-break: break-all; }
.small { font-size: .85rem; }
.center { text-align: center; }
a.tile { color: inherit; }
a.tile:hover { border-color: var(--accent); }

.filters { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; padding: .9rem 1rem; }
.filters input[type=search] { flex: 1 1 260px; }
label.inline { flex-direction: row; align-items: center; gap: .5rem; margin: 0; font-weight: 400; }
label.check input { width: auto; }
select { font: inherit; padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }

.table-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .5rem; }
.table-head p { margin: 0; }
.card.flush { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .6rem .9rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--bg); }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem; background: var(--info-bg); color: var(--info); margin-right: .25rem; }
.badge.warn { background: #fff3d6; color: #7a5300; }
@media (prefers-color-scheme: dark) { .badge.warn { background: #3d3115; color: #f2cf7c; } }

.badge.ok { background: #dcf3e3; color: #145c2c; }
.badge.err { background: var(--danger-bg); color: var(--danger); }
@media (prefers-color-scheme: dark) { .badge.ok { background: #183a24; color: #8fe0a9; } }

.pager { display: flex; gap: 1rem; justify-content: center; align-items: center; padding: 1rem 0; }
a.button { display: inline-block; padding: .45rem .9rem; border-radius: 6px; background: var(--accent); color: var(--accent-text); font-weight: 600; }
a.button.secondary { background: var(--surface); color: var(--accent); border: 1px solid var(--border); }

.props { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1.5rem; margin: 0 0 1rem; }
.props dt { color: var(--muted); }
.props dd { margin: 0; }
@media (max-width: 640px) {
  .props { grid-template-columns: 1fr; }
  .props dd { margin-bottom: .5rem; }
  .topbar { flex-wrap: wrap; gap: .75rem; padding: .75rem 1rem; }
}

.topbar nav { flex-wrap: wrap; }
.topbar nav a { color: var(--muted); padding: .2rem 0; border-bottom: 2px solid transparent; }
.topbar nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; }
.alert.success { background: #dcf3e3; color: #145c2c; }
@media (prefers-color-scheme: dark) { .alert.success { background: #183a24; color: #8fe0a9; } }

.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; vertical-align: middle; }
.dot.on { background: #1f9d55; box-shadow: 0 0 0 3px rgba(31, 157, 85, .2); }
.dot.off { background: var(--border); }
.dot.unknown { background: transparent; border: 1px dashed var(--muted); }
.online-text { color: #1f9d55; font-weight: 600; }
.online-count { color: #1f9d55; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
.grid-2.wide-left { grid-template-columns: 2fr 1fr; }
.grid-2 > .card { margin-bottom: 1rem; }
@media (max-width: 860px) { .grid-2, .grid-2.wide-left { grid-template-columns: 1fr; } }

textarea { font: inherit; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); resize: vertical; }
.actions { display: flex; align-items: center; gap: 1rem; }
.inline-form { display: inline-flex; align-items: center; gap: .5rem; margin: 0; }
.inline-form input, .inline-form select { padding: .35rem .5rem; }
.wrap-form { display: flex; flex-wrap: wrap; margin-bottom: .5rem; }
.row-actions { display: flex; gap: 1rem; align-items: center; justify-content: flex-end; }
.row-actions form { margin: 0; }
.wrap-cell { white-space: normal; max-width: 360px; }
button.danger { background: var(--danger); color: #fff; }
button.small-btn { padding: .4rem .8rem; font-size: .9rem; }
.danger-text, button.link.danger-text { color: var(--danger); }

.badge.os { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.os-row { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; }
.os-chip { color: var(--text); font-variant-numeric: tabular-nums; }
pre.payload { white-space: pre-wrap; word-break: break-all; font-size: .8rem; margin: 0; max-height: 8rem; overflow: auto; }

.card.highlight { border-color: var(--accent); }
tr.muted td { color: var(--muted); }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: 100%; max-width: 360px; }
.login-card button { width: 100%; }
