:root {
  --ink: #0d1726; --ink-2: #2b3747; --muted: #5d6878; --line: #e3e7ee; --soft: #f4f6f9; --bg: #f6f7f9; --card: #fff;
  --brand: #1554d6; --brand-dark: #0f3fa6; --brand-tint: #eaf0fd; --ok: #138a52; --ok-tint: #e7f5ee;
  --warn: #9a5b00; --warn-tint: #fff4e0; --bad: #b42318; --bad-tint: #fdecea;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -0.015em; line-height: 1.2; text-wrap: balance; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.wrap { max-width: 1080px; margin: 0 auto; padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

.topbar { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar .wrap { display: flex; align-items: center; gap: 28px; height: 62px; }
.logo { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); font-weight: 750; font-size: 17px; text-decoration: none !important; }
.logo svg { width: 26px; height: 26px; }
.tabs { display: flex; gap: 4px; height: 100%; }
.tabs a { display: flex; align-items: center; padding: 0 12px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; text-decoration: none; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--brand); }
.who { margin-left: auto; display: flex; gap: 14px; align-items: center; font-size: 14px; color: var(--muted); min-width: 0; }
.who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) { .who span { display: none; } .topbar .wrap { gap: 14px; } }
button.link { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; font-weight: 600; cursor: pointer; }

main { padding-top: 32px; padding-bottom: 64px; }
.loading { color: var(--muted); padding: 40px 0; }
.page-title { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 24px; margin-bottom: 24px; }
.page-title h1 { font-size: 26px; }
.page-title .sub { color: var(--muted); }

.grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
.grid > * { min-width: 0; }
@media (max-width: 860px) { .grid { grid-template-columns: 1fr; } }
.stack { display: grid; gap: 20px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 24px; min-width: 0; }
.card h2 { font-size: 17px; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head .right { margin-left: auto; }

.banner { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 20px; border-radius: 12px; padding: 18px 22px; margin-bottom: 20px; border: 1px solid; }
.banner.ok { background: var(--ok-tint); border-color: #bfe3cf; }
.banner.warn { background: var(--warn-tint); border-color: #f2d6a6; }
.banner b { display: block; font-size: 16px; }
.banner .btn { margin-left: auto; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); background: var(--ok-tint); }
.pill.warn { color: var(--warn); background: var(--warn-tint); }
.pill.bad { color: var(--bad); background: var(--bad-tint); }
.pill.muted { color: var(--muted); background: var(--soft); }

.kv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.kv dt { font-size: 13px; color: var(--muted); }
.kv dd { margin: 4px 0 0; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.kv dd small { display: block; font-size: 13px; font-weight: 400; color: var(--muted); letter-spacing: 0; }
@media (max-width: 560px) { .kv { grid-template-columns: 1fr 1fr; } }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 8px; font: 600 14px/1 var(--font); border: 1px solid transparent; cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-outline { background: #fff; color: var(--ink); border-color: #d3d9e3; }
.btn-outline:hover { border-color: #b7c0ce; }
.btn-danger { background: #fff; color: var(--bad); border-color: #efc4bf; }
.btn-danger:hover { background: var(--bad-tint); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.full { width: 100%; }

.confirm { margin-top: 14px; padding: 14px 16px; border-radius: 10px; background: var(--warn-tint); border: 1px solid #f2d6a6; font-size: 14px; }
.confirm .actions { margin-top: 10px; }

.meter { display: flex; gap: 4px; }
.meter i { width: 22px; height: 6px; border-radius: 3px; background: var(--line); }
.meter i.on { background: var(--brand); }
.meter.full i.on { background: var(--warn); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.list li:first-child { border-top: 0; padding-top: 4px; }
.os { width: 36px; height: 36px; border-radius: 8px; background: var(--soft); display: grid; place-items: center; color: var(--ink-2); flex: none; }
.os svg { width: 18px; height: 18px; }
.list .grow { flex: 1; min-width: 160px; }
.list .name { font-weight: 600; }
.list .meta { font-size: 13px; color: var(--muted); }
.list .meta .live { color: var(--ok); font-weight: 600; }

table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 0 12px 10px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 12px 12px 12px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t td.r, table.t th.r { text-align: right; padding-right: 0; }
.scroll { overflow-x: auto; }
.scroll table { min-width: 640px; }
.empty { color: var(--muted); padding: 8px 0; }

form.stack-form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
input, select { height: 42px; border: 1px solid #cfd6e1; border-radius: 8px; padding: 0 12px; font: 15px var(--font); color: var(--ink); background: #fff; width: 100%; min-width: 0; }
input:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
input[type=checkbox] { width: 18px; height: 18px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.row > .field { flex: 1; min-width: 120px; }
.error { color: var(--bad); font-size: 14px; }
.ok-text { color: var(--ok); font-size: 14px; }

.auth { max-width: 400px; margin: 40px auto; }
.auth h1 { font-size: 26px; }
.auth p.lead { color: var(--muted); margin: 8px 0 24px; }
.auth .card { padding: 28px; }
.auth .foot { margin-top: 18px; font-size: 14px; color: var(--muted); text-align: center; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; min-width: 0; }
.kpi .l { font-size: 13px; color: var(--muted); }
.kpi .v { font-size: 26px; font-weight: 750; letter-spacing: -0.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 13px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.main .v { color: var(--brand); }
@media (max-width: 860px) { .kpis { grid-template-columns: 1fr 1fr; } }
.subtabs { display: flex; gap: 6px; margin-bottom: 20px; flex-wrap: wrap; }
.subtabs button { height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font: 600 14px var(--font); color: var(--ink-2); cursor: pointer; }
.subtabs button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chart svg { width: 100%; height: auto; display: block; }
.events { list-style: none; margin: 0; padding: 0; max-height: 440px; overflow-y: auto; }
.events li { padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.events li:first-child { border-top: 0; }
.events .k { font: 600 11px var(--mono); text-transform: uppercase; color: var(--brand); margin-right: 8px; }
.events .t { float: right; font: 12px var(--mono); color: var(--muted); }
.code { position: relative; margin-top: 12px; }
.code pre { margin: 0; background: #0d1726; color: #e4e9f2; padding: 14px 16px; border-radius: 10px; font: 13px/1.5 var(--mono); overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
.code .btn { position: absolute; top: 8px; right: 8px; }
.bar { width: 100px; height: 6px; background: var(--soft); border-radius: 3px; overflow: hidden; display: inline-block; vertical-align: middle; }
.bar i { display: block; height: 100%; background: var(--brand); }
.notice { background: var(--warn-tint); border: 1px solid #f2d6a6; border-radius: 10px; padding: 12px 16px; font-size: 14px; margin-bottom: 20px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom)); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 14px; box-shadow: 0 12px 30px -10px rgba(0,0,0,.4); z-index: 40; max-width: calc(100vw - 32px); }
#pane { display: grid; gap: 20px; }
#pane > .grid { margin: 0; }
.stack-gap { display: none; }
.list input[type=number] { width: 120px; }
