:root {
  --bg: #f6f8fa; --panel: #ffffff; --panel-2: #f0f3f6; --border: #d8dee4; --text: #1f2328; --muted: #656d76;
  --accent: #2f81f7; --accent-2: #1f6feb; --ok: #1a7f37; --warn: #bf8700; --bad: #cf222e; --info: #8250df;
  --ok-bg: #dafbe1; --warn-bg: #fff8c5; --bad-bg: #ffebe9; --info-bg: #fbefff; --shadow: 0 1px 3px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.06);
  --radius: 10px; --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #0d1117; --panel: #161b22; --panel-2: #1c2129; --border: #30363d; --text: #e6edf3; --muted: #8b949e;
    --ok: #3fb950; --warn: #d29922; --bad: #f85149; --info: #a371f7; --ok-bg: #12261e; --warn-bg: #2a2410; --bad-bg: #2d1416; --info-bg: #221a33; --shadow: 0 1px 3px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3); }
}
:root[data-theme="dark"] { --bg: #0d1117; --panel: #161b22; --panel-2: #1c2129; --border: #30363d; --text: #e6edf3; --muted: #8b949e;
  --ok: #3fb950; --warn: #d29922; --bad: #f85149; --info: #a371f7; --ok-bg: #12261e; --warn-bg: #2a2410; --bad-bg: #2d1416; --info-bg: #221a33; --shadow: 0 1px 3px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3); }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5rem; font-weight: 600; } h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
p { margin: .25rem 0 .75rem; } code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.boot { padding: 4rem; text-align: center; color: var(--muted); }

/* layout */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--border); padding: 14px 12px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; padding: 4px 8px 10px; }
.brand .logo { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); display: grid; place-items: center; color: #fff; font-size: 14px; }
.ws-switch { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); cursor: pointer; }
.ws-switch .name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); }
.nav a:hover { background: var(--panel-2); text-decoration: none; } .nav a.active { background: var(--accent); color: #fff; }
.nav a .badge { margin-left: auto; }
.nav .sep { height: 1px; background: var(--border); margin: 6px 4px; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 24px; border-bottom: 1px solid var(--border); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.topbar .search { flex: 1; max-width: 560px; position: relative; }
.topbar .search input { width: 100%; }
.search-results { position: absolute; top: 40px; left: 0; right: 0; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); max-height: 60vh; overflow: auto; z-index: 20; }
.search-results .item { padding: 8px 12px; display: flex; gap: 10px; align-items: center; cursor: pointer; } .search-results .item:hover { background: var(--panel-2); }
.search-results .group { padding: 6px 12px; font-size: 11px; text-transform: uppercase; color: var(--muted); border-top: 1px solid var(--border); }
.content { padding: 24px; max-width: 1400px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; } .page-head h1 { flex: 1; }
.iconbtn { border: 1px solid var(--border); background: var(--panel); border-radius: 8px; width: 34px; height: 34px; display: grid; place-items: center; cursor: pointer; position: relative; color: var(--text); }
.iconbtn .dot { position: absolute; top: 5px; right: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }

/* cards & grid */
.grid { display: grid; gap: 14px; } .grid.c2 { grid-template-columns: repeat(2, 1fr); } .grid.c3 { grid-template-columns: repeat(3, 1fr); } .grid.c4 { grid-template-columns: repeat(4, 1fr); } .grid.c5 { grid-template-columns: repeat(5, 1fr); }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card.pad0 { padding: 0; } .content > .card + .card, .grid > div > .card + .card, .col > .card + .card { margin-top: 14px; }
.card h2 { display: flex; align-items: center; gap: 8px; } .card h2 .spacer { flex: 1; }
.stat { display: flex; flex-direction: column; gap: 2px; } .stat .v { font-size: 26px; font-weight: 700; line-height: 1.1; } .stat .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.stat.ok .v { color: var(--ok); } .stat.warn .v { color: var(--warn); } .stat.bad .v { color: var(--bad); } .stat.info .v { color: var(--info); }
.row { display: flex; align-items: center; gap: 10px; } .row.wrap { flex-wrap: wrap; } .spacer { flex: 1; } .col { display: flex; flex-direction: column; gap: 6px; }
.list { display: flex; flex-direction: column; } .list > .item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--border); }
.list > .item:first-child { border-top: 0; } .list > .item.link { cursor: pointer; } .list > .item.link:hover { background: var(--panel-2); }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* tables */
table { width: 100%; border-collapse: collapse; } th, td { text-align: left; padding: 9px 12px; border-top: 1px solid var(--border); vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-top: 0; background: var(--panel-2); }
tr.link { cursor: pointer; } tr.link:hover td { background: var(--panel-2); }

/* forms */
input, select, textarea { width: 100%; background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
textarea { min-height: 80px; resize: vertical; } label { display: block; font-size: 12px; color: var(--muted); margin: 8px 0 4px; font-weight: 500; }
.field { margin-bottom: 8px; } .inline { display: flex; gap: 8px; align-items: center; } .inline > * { width: auto; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; } .check input { width: auto; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--panel-2); } .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; } .btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); } .btn.sm { padding: 4px 9px; font-size: 12px; } .btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { border-color: transparent; background: transparent; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.warn { background: var(--warn-bg); color: var(--warn); } .badge.bad { background: var(--bad-bg); color: var(--bad); } .badge.info { background: var(--info-bg); color: var(--info); }
.badge.tag { background: color-mix(in srgb, var(--tag) 18%, transparent); color: var(--tag); border: 1px solid color-mix(in srgb, var(--tag) 40%, transparent); }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.type { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; font-size: 13px; background: var(--panel-2); flex: none; }
.avatar { width: 36px; height: 36px; border-radius: 10px; object-fit: cover; background: var(--panel-2); flex: none; } .avatar.lg { width: 64px; height: 64px; border-radius: 14px; }
.avatar-ph { display: grid; place-items: center; font-size: 18px; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; font-size: 13px; } .kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; } .tabs a { padding: 8px 12px; border-bottom: 2px solid transparent; color: var(--muted); margin-bottom: -1px; }
.tabs a.active { color: var(--text); border-color: var(--accent); } .tabs a:hover { text-decoration: none; color: var(--text); }
.pill-nav { display: flex; gap: 6px; flex-wrap: wrap; } .pill-nav .btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.alert { padding: 10px 12px; border-radius: 8px; border: 1px solid; font-size: 13px; margin-bottom: 10px; }
.alert.warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 40%, transparent); } .alert.bad { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.alert.ok { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 40%, transparent); } .alert.info { background: var(--info-bg); border-color: color-mix(in srgb, var(--info) 40%, transparent); }
.diff { font-family: var(--mono); font-size: 12px; } .diff .de { color: var(--bad); text-decoration: line-through; } .diff .para { color: var(--ok); }
.checklist .item { display: flex; gap: 10px; align-items: center; padding: 6px 0; } .checklist .done { color: var(--ok); } .checklist .todo { color: var(--muted); }
.progress { height: 6px; background: var(--panel-2); border-radius: 4px; overflow: hidden; } .progress > i { display: block; height: 100%; background: var(--accent); }
.spark { display: flex; gap: 2px; align-items: flex-end; height: 34px; } .spark i { flex: 1; min-width: 3px; background: var(--ok); border-radius: 2px 2px 0 0; opacity: .85; } .spark i.f { background: var(--bad); }

/* graph */
.graph { width: 100%; height: 70vh; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.graph .node { cursor: pointer; } .graph .node text { font-size: 11px; fill: var(--text); pointer-events: none; }
.graph .edge { stroke: var(--muted); stroke-width: 1.3; opacity: .6; } .graph .edge-label { font-size: 9px; fill: var(--muted); }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth .card { width: 100%; max-width: 420px; padding: 28px; } .auth .brand { justify-content: center; font-size: 22px; margin-bottom: 8px; }
.auth .tagline { text-align: center; color: var(--muted); margin-bottom: 18px; }

/* modal & toasts */
#modal-root .back { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
#modal-root .modal { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; padding: 20px; box-shadow: var(--shadow); }
#modal-root .modal.wide { max-width: 860px; } #modal-root .modal h2 { margin-bottom: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--panel); border: 1px solid var(--border); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: 360px; font-size: 13px; }
.toast.ok { border-left-color: var(--ok); } .toast.bad { border-left-color: var(--bad); } .toast.warn { border-left-color: var(--warn); }
.dropdown { position: absolute; top: 44px; right: 0; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); min-width: 340px; max-height: 70vh; overflow: auto; z-index: 30; }
.dropdown .item { padding: 10px 12px; border-top: 1px solid var(--border); } .dropdown .item:first-child { border-top: 0; } .dropdown .item.unread { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.menu { position: absolute; left: 12px; right: 12px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); z-index: 30; }
.menu .item { padding: 9px 12px; cursor: pointer; } .menu .item:hover { background: var(--panel-2); }
pre.json { background: var(--panel-2); padding: 10px; border-radius: 8px; overflow: auto; font-size: 12px; max-height: 320px; }
.qr { display: grid; place-items: center; padding: 8px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; } .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; z-index: 40; }
  .sidebar.open { transform: none; } .content { padding: 16px; } .grid.c2, .grid.c3, .grid.c4, .grid.c5 { grid-template-columns: 1fr 1fr; } .kv { grid-template-columns: 1fr; }
  .topbar { padding: 10px 16px; } .menu-btn { display: grid !important; } .topbar .search { max-width: none; }
}
@media (max-width: 560px) { .grid.c2, .grid.c3, .grid.c4, .grid.c5 { grid-template-columns: 1fr; } th, td { padding: 7px 8px; } .hide-sm { display: none; } }
.menu-btn { display: none; }
