:root {
  color-scheme: light;
  --bg: #f5f7fa; --surface: #ffffff; --subtle: #f0f3f8; --text: #14213d; --muted: #536079; --line: #e1e6ee; --line-strong: #cbd3e0;
  --accent: #2154c4; --accent-hover: #1a44a3; --accent-soft: #e8effc;
  --green: #14692c; --green-bg: #e2f5e7; --green-dot: #1f9d43;
  --amber: #8a5200; --amber-bg: #fff2d2; --amber-dot: #d98a00;
  --red: #b3261e; --red-bg: #fde8e6; --red-dot: #d93a30;
  --grey: #475066; --grey-bg: #e9ecf2; --grey-dot: #8b94a7;
  --radius: 10px; --shadow: 0 1px 2px rgba(20, 33, 61, .05);
  --side: 244px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.005em; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; font-size: 12.5px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 6px; z-index: 50; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
#app { min-height: 100vh; }
body.authed #app { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); padding: 16px 12px; z-index: 30; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.side-brand strong { display: block; font-size: 14.5px; line-height: 1.2; }
.side-brand small, .side-user small { display: block; color: var(--muted); font-size: 12px; line-height: 1.3; }
.logo { width: 32px; height: 32px; border-radius: 8px; background: var(--text); color: #fff; display: grid; place-items: center; flex: none; }
.logo svg { width: 18px; height: 18px; }
#nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
#nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--muted); font-weight: 500; text-decoration: none; }
#nav a:hover { background: var(--subtle); color: var(--text); }
#nav a.on { background: var(--accent-soft); color: var(--accent); }
#nav svg { width: 18px; height: 18px; flex: none; }
.side-user { border-top: 1px solid var(--line); padding: 12px 4px 0; display: grid; gap: 10px; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who strong { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 650; font-size: 13px; flex: none; text-transform: uppercase; }
.content { min-width: 0; }
.topbar { display: none; align-items: center; gap: 10px; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
#scrim { position: fixed; inset: 0; background: rgba(20, 33, 61, .35); z-index: 25; }
main { max-width: 1240px; margin: 0 auto; padding: 28px 28px 64px; outline: none; }
body:not(.authed) main { max-width: none; padding: 0; }

@media (max-width: 1023px) {
  body.authed #app { display: block; }
  .topbar { display: flex; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 264px; transform: translateX(-102%); transition: transform .15s ease; box-shadow: 0 8px 30px rgba(20, 33, 61, .18); }
  body.menu-open .sidebar { transform: none; }
  main { padding: 20px 18px 56px; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }
@media (max-width: 600px) { main { padding: 16px 12px 48px; } h1 { font-size: 20px; } }

/* ---------- page furniture ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { color: var(--muted); margin-top: 4px; }
.crumbs { font-size: 13px; margin-bottom: 8px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.section { margin-top: 28px; }
.section > .sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.sec-head p { color: var(--muted); font-size: 13px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 16px 18px; }
.stack { display: grid; gap: 16px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }

/* ---------- stat cards ---------- */
.stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.stat { padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 28px; font-weight: 650; line-height: 1.2; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .hint { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.ok .value { color: var(--green); } .stat.bad .value { color: var(--red); }
@media (max-width: 1180px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } .stat .value { font-size: 24px; } }

/* ---------- status ---------- */
.status { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 8px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.status.READY, .status.ok { background: var(--green-bg); color: var(--green); }
.status.STARTING, .status.DEGRADED, .status.warn { background: var(--amber-bg); color: var(--amber); }
.status.OFFLINE, .status.NOT_READY, .status.bad { background: var(--red-bg); color: var(--red); }
.status.DISABLED, .status.off { background: var(--grey-bg); color: var(--grey); }
.tag { display: inline-block; background: var(--subtle); border: 1px solid var(--line); border-radius: 6px; padding: 0 7px; font-size: 12px; color: var(--muted); margin: 0 4px 2px 0; }
.tag.accent { background: var(--accent-soft); border-color: transparent; color: var(--accent); }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; background: #fafbfd; white-space: nowrap; }
thead th:first-child { border-top-left-radius: var(--radius); } thead th:last-child { border-top-right-radius: var(--radius); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbfd; }
td a strong, td code { white-space: nowrap; }
td .sub { display: block; color: var(--muted); font-size: 12px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.act { text-align: right; white-space: nowrap; }
.rowbtns { display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; } td.act .rowbtns { flex-wrap: nowrap; }
@media (max-width: 900px) {
  .tablewrap { overflow: visible; }
  table.stackable, .stackable thead, .stackable tbody, .stackable tr, .stackable td { display: block; }
  .stackable thead { position: absolute; left: -9999px; }
  .stackable tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
  .stackable tr:last-child { border-bottom: 0; }
  .stackable td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .stackable td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-align: left; flex: none; }
  .stackable td[data-label=""]::before, .stackable td:not([data-label])::before { content: none; }
  .stackable td.act { justify-content: flex-end; padding-top: 8px; }
  .stackable tbody tr:hover td { background: none; }
}

/* ---------- meters ---------- */
.meter { display: inline-flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.meter .track { width: 64px; height: 6px; background: var(--grey-bg); border-radius: 3px; overflow: hidden; flex: none; }
.meter .track i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.meter.hot .track i { background: var(--red-dot); } .meter.warm .track i { background: var(--amber-dot); }
.meter.big { display: flex; width: 100%; } .meter.big .track { flex: 1; width: auto; height: 8px; } .meter.big span:last-child { min-width: 36px; text-align: right; }

/* ---------- description lists ---------- */
.kv { display: grid; grid-template-columns: minmax(120px, 40%) 1fr; column-gap: 14px; margin: 0; }
.kv dt, .kv dd { padding: 9px 0; border-bottom: 1px solid var(--line); margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { overflow-wrap: anywhere; }
.kv dt:nth-last-of-type(1), .kv dd:last-child { border-bottom: 0; }
.card > h2, .card > .card-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card > .card-body { padding: 4px 18px 8px; }
.card > .card-body.pad { padding: 16px 18px; }

/* ---------- buttons & forms ---------- */
.btn, button { font: inherit; font-weight: 550; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); cursor: pointer; display: inline-flex; align-items: center; gap: 8px; line-height: 1.3; text-decoration: none; }
.btn:hover, button:hover { background: var(--subtle); text-decoration: none; }
.btn.primary, button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover, button.primary:hover { background: var(--accent-hover); }
.btn.danger, button.danger { color: var(--red); border-color: #efc4c0; }
.btn.danger:hover, button.danger:hover { background: var(--red-bg); }
.btn.ghost, button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover, button.ghost:hover { background: var(--subtle); color: var(--text); }
.btn.small, button.small { padding: 4px 10px; font-size: 12.5px; border-radius: 7px; }
.btn.icon-btn { padding: 6px; } .btn svg { width: 16px; height: 16px; flex: none; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select { font: inherit; padding: 8px 11px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--text); max-width: 100%; width: 100%; }
input::placeholder { color: #8791a5; }
input:hover, select:hover { border-color: #aab4c6; }
input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
input[type=checkbox] { width: auto; }
label { display: block; font-size: 13px; font-weight: 550; margin: 0 0 5px; }
.field { min-width: 0; }
.field .hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.field.invalid input { border-color: var(--red-dot); }
.field .ferr { color: var(--red); font-size: 12.5px; margin-top: 4px; }
.formgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; align-items: end; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 0; padding: 8px 0; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none; }
.tabs a:hover { color: var(--text); }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.filters .field { width: 200px; }

/* ---------- notices, empty, loading ---------- */
.notice { border: 1px solid var(--line); border-left-width: 4px; border-radius: 8px; padding: 12px 14px; background: var(--surface); display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.notice.ok { border-left-color: var(--green-dot); } .notice.warn { border-left-color: var(--amber-dot); } .notice.bad { border-left-color: var(--red-dot); }
.notice p + p { color: var(--muted); margin-top: 2px; }
.secret { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; background: var(--subtle); border: 1px solid var(--line); padding: 8px 12px; border-radius: 8px; overflow-wrap: anywhere; margin-top: 8px; user-select: all; }
.empty { text-align: center; padding: 44px 20px; }
.empty .ico { width: 44px; height: 44px; margin: 0 auto 12px; border-radius: 50%; background: var(--subtle); color: var(--muted); display: grid; place-items: center; }
.empty .ico svg { width: 22px; height: 22px; }
.empty h3 { font-size: 15px; } .empty p { color: var(--muted); margin: 4px auto 14px; max-width: 420px; }
.empty.compact { padding: 26px 20px; } .empty.compact p { margin-bottom: 0; }
.skel { display: grid; gap: 12px; }
.skel i { display: block; height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--grey-bg), #f3f5f9, var(--grey-bg)); background-size: 200% 100%; animation: sh 1.4s linear infinite; }
.skel .blk { height: 84px; border-radius: var(--radius); }
@keyframes sh { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel i { animation: none; } }
.diag { white-space: pre-wrap; margin: 8px 0 0; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: 10px 16px; border-radius: 8px; display: none; max-width: 92vw; z-index: 60; box-shadow: 0 6px 24px rgba(20, 33, 61, .25); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.login-box { width: 100%; max-width: 420px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; justify-content: center; }
.login-brand .logo { width: 40px; height: 40px; border-radius: 10px; } .login-brand .logo svg { width: 22px; height: 22px; }
.login-brand h1 { font-size: 22px; } .login-brand p { color: var(--muted); font-size: 13.5px; }
.login-card { padding: 26px; }
.login-card h2 { font-size: 17px; margin-bottom: 4px; padding: 0; border: 0; display: block; } .login-card > p { color: var(--muted); margin-bottom: 18px; }
.login-card form { display: grid; gap: 14px; }
.pw { position: relative; }
.pw input { padding-right: 44px; }
.pw button { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); padding: 6px; border-color: transparent; background: transparent; color: var(--muted); }
.pw button:hover { color: var(--text); }
.formerr { background: var(--red-bg); color: var(--red); border-radius: 8px; padding: 9px 12px; font-size: 13px; }
.secure { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 16px; font-size: 12.5px; color: var(--muted); }
.secure svg { width: 14px; height: 14px; } .secure.ok { color: var(--green); } .secure.warn { color: var(--amber); }
@media (max-width: 480px) { .login-card { padding: 20px 16px; } }
