:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --line: #e7ebf0;
  --line-2: #f0f2f5;
  --text: #1d2129;
  --muted: #86909c;
  --primary: #0058e9;
  --primary-2: #1a6fff;
  --primary-soft: #e8f3ff;
  --danger: #f53f3f;
  --warn: #ff7d00;
  --ok: #00b42a;
  --sidebar: #ffffff;
  --sidebar-text: #4e5969;
  --radius: 6px;
  --radius-sm: 4px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04);
  --header-h: 56px;
  --side-w: 224px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
.sidebar a:hover, .page-tabs a:hover, .auth-tabs a:hover, .topbar a:hover { text-decoration: none; }
button, input, select, textarea { font: inherit; }
::placeholder { color: #c0c4cc; }
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.btn, .nav-toggle, .nav-close, .sidebar a, .page-tabs a { touch-action: manipulation; }
.btn:focus-visible, .sidebar a:focus-visible, .nav-toggle:focus-visible, .nav-close:focus-visible, .user-chip:focus-visible {
  outline-offset: 1px;
}
body.modal-open { overflow: hidden; }

.layout { display: flex; min-height: 100vh; min-height: 100dvh; overflow-x: clip; }
.sidebar-mask {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 40;
}
.sidebar {
  width: var(--side-w);
  background: var(--sidebar);
  color: var(--sidebar-text);
  border-right: 1px solid var(--line);
  padding: 0 0 24px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  z-index: 50;
  scrollbar-width: thin;
  scrollbar-color: #d0d5dd transparent;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: #d0d5dd; border-radius: 6px; }
.sidebar .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--header-h);
  height: calc(var(--header-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 16px 0;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .02em;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}
.logo-mark {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  flex-shrink: 0;
}
.logo-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; line-height: 1.15; flex: 1; }
.logo-text small { font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.nav-close {
  display: none;
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: var(--radius);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  margin-left: auto;
}
.nav-close:hover { background: var(--line-2); color: var(--text); }
.sidebar nav { padding: 8px 10px 24px; }
.sidebar .group {
  font-size: 11px;
  color: var(--muted);
  padding: 16px 10px 6px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.sidebar .group:first-child { padding-top: 6px; }
.sidebar .group:not(:first-child) {
  margin-top: 8px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.sidebar a {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--sidebar-text);
  padding: 8px 10px;
  border-radius: var(--radius);
  margin-bottom: 2px;
  min-height: 36px;
  font-size: 13px;
  transition: background-color .15s ease, color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.sidebar a:hover { background: var(--line-2); color: var(--text); transform: translateX(1px); }
.sidebar a.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
  box-shadow: inset 3px 0 var(--primary);
}
.node-detail-section { margin-top: 12px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  min-height: var(--header-h);
  height: calc(var(--header-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 16px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-user { display: flex; align-items: center; gap: 8px; flex-shrink: 0; position: relative; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-actions form { display: inline; margin: 0; }
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 10px;
  background: var(--line-2);
  border-radius: 20px;
  max-width: 220px;
  border: 0;
  font: inherit;
  color: inherit;
  cursor: default;
}
.user-chip .muted {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}
.nav-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--text);
  flex-shrink: 0;
}
.nav-toggle svg { display: block; }
.content { padding: 18px 20px 28px; flex: 1; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card > strong:first-child, .card h3 { font-size: 15px; font-weight: 600; }
.card .label { color: var(--muted); font-size: 12px; }
.card .value { font-size: 22px; font-weight: 700; margin-top: 6px; color: var(--text); }
.table-wrap { overflow: auto; -webkit-overflow-scrolling: touch; margin: 4px -4px 0; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table { width: 100%; border-collapse: collapse; min-width: 520px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); text-align: left; white-space: nowrap; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; background: #f7f8fa; }
td:first-child, th:first-child { padding-left: 14px; }
td:last-child, th:last-child { padding-right: 14px; }
.table-wrap table tr:last-child td { border-bottom: 0; }
.table-wrap table tr:first-child th {
  position: sticky;
  top: 0;
  z-index: 1;
  box-shadow: 0 1px 0 var(--line);
}
.table-wrap input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}
.table-filter {
  width: 200px;
  max-width: 100%;
  min-height: 32px;
  padding: 5px 10px;
  margin: 0;
}
tr:hover td { background: #fafbfc; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e5e6eb;
  border-radius: var(--radius);
  padding: 7px 14px;
  cursor: pointer;
  background: #f2f3f5;
  color: #1d2129;
  font-size: 13px;
  line-height: 1.4;
  min-height: 32px;
  text-align: center;
  transition: background-color .15s ease, color .15s ease, transform .12s ease, box-shadow .15s ease, opacity .15s ease;
}
.btn:hover { background: #e5e6eb; color: #1d2129; }
.btn.primary { background: var(--primary); color: #fff; border-color: transparent; }
.btn.primary:hover { background: var(--primary-2); color: #fff; }
.btn.danger { background: var(--danger); color: #fff; border-color: transparent; }
.btn.danger:hover { filter: brightness(.96); color: #fff; }
.btn.ghost { background: #fff; color: #1d2129; border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--line-2); color: #1d2129; }
.btn.copy {
  padding: 0 8px;
  min-height: 22px;
  height: 22px;
  font-size: 12px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: var(--radius-sm);
}
.btn.copy:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }
.btn:active { transform: scale(.98); }
.btn:disabled, .btn.is-busy { opacity: .65; pointer-events: none; }
.btn.is-busy { position: relative; color: transparent !important; }
.btn.is-busy::after {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid var(--muted);
  border-right-color: transparent;
  border-radius: 50%;
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  animation: spin .7s linear infinite;
}
.btn.block { width: 100%; }
.btn.sm { padding: 5px 10px; font-size: 12px; min-height: 28px; }
.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 18px;
  background: #f2f3f5;
  color: var(--sidebar-text);
}
.badge.on { background: #e8ffea; color: #009a29; }
.badge.off { background: #ffece8; color: #cb2634; }
.badge.warn { background: #fff7e8; color: #d25f00; }
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.toolbar > div { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.card > .toolbar + .hint { margin: 0 0 12px; }
.card > .hint:first-child { margin-top: 0; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
  min-height: 36px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%2386909c' d='M1 1l5 5 5-5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
input:focus, select:focus, textarea:focus {
  outline: 0;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(0, 88, 233, .12);
}
input[type="checkbox"], input[type="radio"] {
  width: 16px;
  height: 16px;
  min-height: 0;
  padding: 0;
  accent-color: var(--primary);
  cursor: pointer;
}
textarea { min-height: 90px; font-family: Consolas, "Courier New", monospace; }
label { display: block; margin: 10px 0; color: var(--muted); font-size: 13px; }
label > input, label > select, label > textarea { margin-top: 6px; color: var(--text); }
.modal .box > form > label:first-of-type,
.modal .box form > label:first-of-type { margin-top: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 4px 12px; }
.grid-2 > label, .grid-3 > label { margin: 8px 0; }
.opt-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 2px 0 0;
}
.opt-head h3 { margin: 0; }
.opt-status { font-size: 12px; color: var(--muted); margin: 0; }
.preset-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0 8px;
}
.preset-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
  min-height: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  box-shadow: none;
  font: inherit;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}
.preset-card:hover {
  border-color: #bedaff;
  background: #f7fbff;
  transform: none;
}
.preset-card:active { transform: none; }
.preset-card.on {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 1px var(--primary);
}
.preset-card .preset-name {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.preset-card .preset-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}
.preset-card .preset-meta {
  font-size: 11px;
  color: #4e5969;
  font-variant-numeric: tabular-nums;
  line-height: 1.45;
}
.preset-card.on .preset-meta { color: var(--primary); }
.opt-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 8px;
}
.opt-section {
  margin-top: 6px;
  padding-top: 2px;
}
.opt-section > h4 {
  margin: 16px 0 2px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.opt-section > h4:first-child { margin-top: 8px; }
.modal {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .45);
  display: flex; align-items: flex-end; justify-content: center; z-index: 60;
  padding: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .2s ease, visibility .2s ease;
}
.modal.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.modal .box {
  background: #fff;
  width: 560px;
  max-width: 100%;
  border-radius: 8px 8px 0 0;
  padding: 22px 20px calc(18px + env(safe-area-inset-bottom));
  max-height: 92vh;
  overflow: auto;
  transform: translateY(18px);
  transition: transform .22s ease;
  position: relative;
}
.modal .box::before {
  content: '';
  display: none;
  width: 36px;
  height: 4px;
  background: #d0d5dd;
  border-radius: 2px;
  margin: 0 auto 12px;
}
.modal.show .box { transform: translateY(0); }
.modal .box.wide { width: 720px; }
.modal h3 { margin: 0 36px 14px 0; font-size: 16px; font-weight: 600; }
.modal-x {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 0;
}
.modal-x:hover { background: var(--line-2); color: var(--text); }
.alert { padding: 10px 12px; border-radius: var(--radius); margin: 0 0 14px; user-select: text; -webkit-user-select: text; font-size: 13px; }
.alert.err { background: #ffece8; color: #cb2634; }
.alert.ok { background: #e8ffea; color: #009a29; }
.alert.warn { background: #fff7e8; color: #d25f00; }
.muted { color: var(--muted); }
.warn-text { color: #d25f00; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.6; }
.hint.warn-text { color: #d25f00; }
.hint code, td code { font-size: 12px; }
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eef2f8;
  padding: 16px;
}
.auth-card {
  width: 400px;
  max-width: 100%;
  background: #fff;
  border-radius: 8px;
  padding: 32px 28px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.auth-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.auth-kicker {
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  line-height: 1.4;
  white-space: nowrap;
}
.auth-lead { margin: 10px 0 18px; font-size: 13px; line-height: 1.6; }
.auth-form { margin-top: 4px; }
.auth-card .btn.block { margin-top: 12px; }
.auth-form label { margin: 12px 0; }
.auth-context {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 18px 0;
  padding: 12px 14px;
  background: var(--line-2);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
}
.auth-context strong { font-size: 15px; }
.auth-context span { color: var(--muted); font-size: 12px; }
.auth-links { display: flex; justify-content: center; gap: 8px; margin-top: 16px; font-size: 12px; }
.auth-links span { color: var(--line); }
.auth-switch { margin: 14px 0 0; text-align: center; color: var(--muted); font-size: 12px; }
.captcha-label { display: block; }
.captcha-row { display: flex; align-items: center; gap: 10px; min-height: 44px; margin: 7px 0 8px; }
.captcha-refresh { display: inline-flex; flex: 0 0 auto; border-radius: var(--radius); line-height: 0; background: #f7f8fa; transition: box-shadow .15s ease, transform .15s ease; }
.captcha-image { display: block; width: 120px; height: 44px; border: 1px solid var(--line); border-radius: var(--radius); object-fit: cover; }
.captcha-refresh:hover { box-shadow: 0 0 0 3px var(--primary-soft); transform: translateY(-1px); }
.captcha-refresh:hover .captcha-image { border-color: var(--primary); }
.captcha-tip { color: var(--muted); font-size: 12px; }
.captcha-refresh-link { color: var(--primary); white-space: nowrap; }
.captcha-input { letter-spacing: .16em; text-transform: uppercase; }
.auth-tabs {
  display: flex;
  margin: -32px -28px 24px;
  border-bottom: 1px solid var(--line);
}
.auth-tabs a {
  flex: 1;
  text-align: center;
  padding: 14px 8px;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
}
.auth-tabs a:hover { color: var(--text); background: var(--line-2); }
.auth-tabs a.active {
  color: var(--primary);
  box-shadow: inset 0 -2px 0 var(--primary);
  background: transparent;
}
.install-card { width: 640px; }
.install-steps, .setup-steps {
  margin: 10px 0 14px;
  padding-left: 22px;
}
.install-steps li, .setup-steps li {
  margin: 8px 0;
  line-height: 1.6;
}
.setup-steps .hint { margin: 4px 0 8px; }
.setup-steps .btn { margin-right: 8px; }
.field-with-btn {
  display: flex;
  gap: 8px;
  align-items: stretch;
  flex-wrap: wrap;
  width: 100%;
}
.field-with-btn input,
.field-with-btn select {
  flex: 1 1 220px;
  min-width: 0;
  width: auto;
}
.field-with-btn .btn {
  flex: 0 0 auto;
  white-space: nowrap;
  align-self: stretch;
}
.hint .btn { margin: 4px 0 0 8px; }
.env-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 12px 0 4px; flex-wrap: wrap; }
.env-head h3 { margin: 0; font-size: 15px; }
.env-table-wrap { overflow: auto; margin: 10px 0; -webkit-overflow-scrolling: touch; }
table.env-table { min-width: 0; }
table.env-table td { white-space: normal; font-size: 13px; vertical-align: top; }
.env-req { font-size: 11px; color: var(--danger); }
.brand { font-size: 22px; font-weight: 700; color: var(--primary); display: flex; align-items: center; gap: 10px; }
.mail-settings { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.mail-settings-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.mail-settings-head h3 { margin: 0; font-size: 15px; }
.mail-settings-head .hint { margin: 3px 0 0; }
.mail-status { flex: 0 0 auto; border-radius: 999px; padding: 4px 9px; font-size: 11px; font-weight: 600; }
.mail-status.is-on { color: var(--ok); background: #e8ffea; }
.mail-status.is-off { color: var(--muted); background: var(--line-2); }
.mail-status.is-pending { color: var(--primary); background: var(--primary-soft); }
.mail-primary-fields { margin-top: 4px; }
.mail-channel-panel { margin: 12px 0 4px; padding: 14px; background: #fbfcfe; border: 1px solid var(--line); border-radius: var(--radius); }
.mail-panel-title { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.mail-panel-title strong { font-size: 13px; }
.mail-panel-title span { color: var(--muted); font-size: 12px; }
.mail-settings-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }
.mail-settings-actions .hint { margin: 0; }
code { background: #f2f3f5; padding: 1px 6px; border-radius: var(--radius-sm); font-size: 12px; font-family: ui-monospace, Consolas, "Courier New", monospace; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi-sub.up { color: var(--ok); }
.kpi-sub.down { color: var(--danger); }
.kpi-unit { font-size: 12px; font-weight: 600; color: var(--muted); }
.chart-box {
  height: 240px;
  position: relative;
  margin-top: 8px;
}
.chart-box-sm { height: 180px; }
.chart-box svg { width: 100%; height: 100%; display: block; }
.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
  pointer-events: none;
}
.chart-tip {
  position: absolute;
  pointer-events: none;
  background: #1d2129;
  color: #fff;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  display: none;
  z-index: 2;
  white-space: nowrap;
  transform: translate(-50%, -120%);
}
.chart-tabs { display: flex; gap: 6px; }
.chart-tabs .btn.active { background: var(--primary); color: #fff; }
.hbar { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.hbar .name {
  width: 108px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  flex-shrink: 0;
  color: var(--text);
}
.hbar .bar {
  flex: 1;
  height: 8px;
  background: #f2f3f5;
  border-radius: 4px;
  overflow: hidden;
  min-width: 0;
}
.hbar .bar i {
  display: block;
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
}
.hbar .val { width: 84px; text-align: right; font-size: 12px; color: var(--muted); flex-shrink: 0; }
.meter {
  height: 8px;
  background: #f2f3f5;
  border-radius: 4px;
  overflow: hidden;
}
.meter > i { display: block; height: 100%; background: var(--primary); border-radius: 4px; max-width: 100%; }
.meter.warn > i { background: var(--warn); }
.meter.danger > i { background: var(--danger); }
.meter-row {
  display: grid;
  grid-template-columns: 36px 1fr 48px;
  gap: 8px;
  align-items: center;
  margin: 6px 0;
  font-size: 12px;
  color: var(--muted);
}
.meter-row em { font-style: normal; text-align: right; color: var(--text); }
.res-stack { min-width: 128px; max-width: 168px; }
.res-stack .meter-row { margin: 2px 0; grid-template-columns: 28px 1fr 36px; }
.node-cell strong { display: block; font-weight: 600; }
.node-cell .kpi-sub { margin-top: 2px; }
.node-flags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.node-meter { padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.node-meter:last-child { border-bottom: 0; }
.node-meter-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.node-detail-head { margin-bottom: 12px; }
.node-detail-grid { gap: 12px; margin-bottom: 12px; }
.card.flat { box-shadow: none; border: 1px solid var(--line-2); padding: 12px 14px; margin: 0; }
.card.flat .toolbar { margin-bottom: 8px; }
table.compact th, table.compact td { padding: 6px 8px; font-size: 12px; }
tr.warn-row td { color: #d25f00; }
.quota-row { margin: 12px 0; }
.quota-head { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; margin-bottom: 6px; flex-wrap: wrap; }
.status-pills { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.donut-wrap { display: flex; justify-content: center; margin: 8px 0 16px; }
.chart-donut { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; justify-content: center; }
.chart-donut-legend { font-size: 12px; color: var(--muted); }
.chart-donut-legend div { margin: 4px 0; display: flex; align-items: center; gap: 6px; }
.chart-donut-legend i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
html { overscroll-behavior: none; }
.sidebar { overscroll-behavior: contain; }
.sidebar a { transition: background-color .15s ease, color .15s ease; }
.content { animation: fade-up .22s ease; }
.toast-wrap {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  align-items: flex-end;
}
.toast {
  min-width: 220px;
  max-width: 480px;
  max-height: 50vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 10px 14px;
  border-radius: 6px;
  background: #1d2129;
  color: #fff;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .14);
  animation: toast-in .22s ease;
  white-space: pre-wrap;
  pointer-events: auto;
  user-select: text;
  -webkit-user-select: text;
}
.toast.ok { background: #009a29; }
.toast.err { background: #cb2634; }
.toast.warn { background: #d25f00; }
.toast.out { animation: toast-out .18s ease forwards; }
.deploy-dock {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100% - 32px);
  padding: 10px 14px;
  border-radius: 8px;
  background: #1d2129;
  color: #fff;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
.deploy-dock a { color: #9fceff; }
.deploy-dock .btn,
.deploy-dock .btn.ghost {
  color: #fff;
  background: transparent;
  border: 1px solid rgba(255,255,255,.45);
}
.deploy-dock .btn:hover,
.deploy-dock .btn.ghost:hover {
  color: #fff;
  background: rgba(255,255,255,.12);
}
.toast-body {
  word-break: break-all;
  overflow: auto;
  min-height: 0;
  flex: 1;
  white-space: pre-wrap;
}
.toast-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-shrink: 0;
}
.toast-copy {
  border: 0;
  background: rgba(255, 255, 255, .2);
  color: #fff;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.toast-copy:hover { background: rgba(255, 255, 255, .32); }
.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 28px 12px;
  font-size: 13px;
}
.empty-row td { white-space: normal; background: #fff !important; }
.steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 10px;
}
.step {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 6px 12px 6px 6px;
  font-size: 13px;
  color: var(--text);
}
.step b {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}
.card + .card { margin-top: 14px; }
.cards .card + .card,
.grid-2 .card + .card,
.grid-3 .card + .card { margin-top: 0; }
.toolbar strong { font-size: 15px; }
.table-actions { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.table-actions .btn.sm { padding: 4px 8px; min-height: 26px; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.modal-actions .btn {
  min-width: 88px;
  background: #f2f3f5;
  color: #1d2129;
  border: 1px solid #e5e6eb;
}
.modal-actions .btn:hover { background: #e5e6eb; color: #1d2129; }
.modal-actions .btn.primary { background: var(--primary); color: #fff; border-color: transparent; }
.modal-actions .btn.primary:hover { background: var(--primary-2); color: #fff; }
.modal-actions .btn.danger { background: var(--danger); color: #fff; border-color: transparent; }
.modal-actions .btn.danger:hover { filter: brightness(.96); color: #fff; }
.page-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border-bottom: 1px solid var(--line);
  margin: 0 0 14px;
}
.page-tabs a {
  padding: 10px 14px;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
}
.page-tabs a:hover { color: var(--text); }
.page-tabs a.active {
  color: var(--primary);
  box-shadow: inset 0 -2px 0 var(--primary);
}
.td-wrap { white-space: normal; word-break: break-all; max-width: 280px; }
.inline-copy { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; vertical-align: middle; max-width: 100%; }
.inline-copy code { word-break: break-all; }
td.inline-copy { display: table-cell; }
.log-view {
  margin-top: 12px;
  max-height: 480px;
  overflow: auto;
  white-space: pre-wrap;
  background: #f7f8fa;
  padding: 12px;
  border-radius: var(--radius);
  font-size: 12px;
  min-height: 48px;
}
input[readonly] { background: #f7f8fa; color: var(--muted); }
.meter > i, .hbar .bar i { transition: width .45s ease; }
.auth-card { animation: fade-up .28s ease; }
@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(-6px); }
}
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

@media (min-width: 769px) {
  .modal { align-items: center; padding: 24px; }
  .modal .box { border-radius: 10px; padding: 24px 22px 20px; transform: translateY(10px) scale(.98); }
  .modal.show .box { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 1100px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .preset-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .nav-toggle, .nav-close { display: inline-flex; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(300px, calc(100vw - 48px));
    height: 100%;
    height: 100dvh;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: none;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    padding-left: env(safe-area-inset-left, 0px);
    z-index: 50;
  }
  body.nav-open .sidebar { transform: none; box-shadow: 8px 0 28px rgba(0,0,0,.18); }
  body.nav-open .sidebar-mask { display: block; }
  body.nav-open, html.nav-open { overflow: hidden; }
  .sidebar a {
    min-height: 44px;
    padding: 10px 14px;
    font-size: 15px;
  }
  .sidebar .group { padding-left: 14px; padding-right: 14px; }
  .content {
    padding: 12px 12px calc(20px + env(safe-area-inset-bottom, 0px));
  }
  .cards { grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .preset-grid { grid-template-columns: 1fr; }
  .topbar { padding: env(safe-area-inset-top, 0px) 10px 0; gap: 8px; }
  .topbar h1 { font-size: 15px; }
  .user-chip {
    cursor: pointer;
    max-width: 132px;
    min-height: 36px;
    padding: 4px 10px;
    background: var(--line-2);
  }
  .user-chip .badge { display: none; }
  .user-chip::after {
    content: '';
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--muted);
    flex-shrink: 0;
  }
  .topbar-actions {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    flex-direction: column;
    align-items: stretch;
    min-width: 148px;
    padding: 8px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
    z-index: 40;
  }
  body.user-menu-open .topbar { z-index: 45; }
  body.user-menu-open .topbar-actions { display: flex; }
  .topbar-actions .btn { width: 100%; min-height: 40px; }
  .topbar-actions form { width: 100%; }
  .card { padding: 12px; }
  .card .value { font-size: 18px; word-break: break-all; }
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .toolbar > div:not(.chart-tabs) {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
  }
  .toolbar > .btn { width: 100%; min-height: 40px; }
  .toolbar > div:not(.chart-tabs) .btn { flex: 1 1 auto; min-width: 96px; min-height: 40px; }
  .toolbar .table-filter { width: 100%; flex: 1 1 100%; }
  .chart-tabs { width: 100%; }
  .chart-tabs .btn { flex: 1; min-height: 36px; }
  table { min-width: 0; }
  th, td { padding: 10px 8px; }
  td.td-wrap, .empty-row td { white-space: normal; }
  .table-wrap th:last-child,
  .table-wrap td:last-child {
    position: sticky;
    right: 0;
    background: #fff;
    box-shadow: -8px 0 8px -8px rgba(0, 0, 0, .12);
    z-index: 1;
  }
  .table-wrap th:last-child {
    background: #f7f8fa;
    z-index: 2;
  }
  .table-wrap tr:hover td:last-child { background: #fafbfc; }
  .table-wrap .empty-row td {
    position: static;
    box-shadow: none;
  }
  .table-actions {
    flex-direction: column;
    align-items: stretch;
    min-width: 76px;
  }
  .table-actions .btn.sm { width: 100%; min-height: 36px; }
  .btn { min-height: 40px; }
  .btn.sm { min-height: 36px; }
  .btn.copy { min-height: 22px; height: 22px; padding: 0 8px; }
  label { margin: 8px 0; }
  input, select, textarea { font-size: 16px; min-height: 42px; }
  input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; min-height: 0; }
  .field-with-btn { flex-direction: column; }
  .field-with-btn input, .field-with-btn select { width: 100%; flex: 1 1 auto; }
  .field-with-btn .btn { width: 100%; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .preset-grid { grid-template-columns: 1fr; }
  .preset-card { min-height: 44px; }
  .auth-card { padding: 24px 16px; }
  .auth-kicker { font-size: 10px; }
  .captcha-row { align-items: flex-start; flex-wrap: wrap; }
  .captcha-tip { padding-top: 13px; }
  .mail-settings-head, .mail-settings-actions { align-items: stretch; flex-direction: column; }
  .mail-settings-actions .btn { width: 100%; }
  .auth-body { padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px)); align-items: flex-start; padding-top: max(24px, env(safe-area-inset-top, 0px)); }
  .install-card { width: 100%; }
  .toast-wrap {
    left: 12px;
    right: 12px;
    top: calc(12px + env(safe-area-inset-top, 0px));
    align-items: stretch;
  }
  .toast { max-width: none; min-width: 0; }
  .chart-box { height: 180px; }
  .chart-box-sm { height: 140px; }
  .hbar .name { width: 72px; }
  .hbar .val { width: 64px; }
  .page-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-left: -4px;
    margin-right: -4px;
    padding: 0 4px;
  }
  .page-tabs a { white-space: nowrap; padding: 10px 12px; }
  .modal .box::before { display: block; }
  .modal .box { max-height: min(92vh, calc(100dvh - 8px)); }
  .modal-x { width: 40px; height: 40px; top: 8px; right: 8px; }
  .modal-actions { flex-direction: column; }
  .modal-actions .btn { width: 100%; min-height: 44px; }
  .deploy-dock {
    left: 12px;
    right: 12px;
    max-width: none;
    transform: none;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    flex-wrap: wrap;
  }
  .inline-copy { flex-wrap: wrap; }
  .inline-copy code { word-break: break-all; }
  .td-wrap { max-width: 180px; }
}

@media (max-width: 420px) {
  .cards { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 14px; }
}
