:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-subtle: #fafbfc;
  --surface-hover: #f5f8fa;
  --text: #15181d;
  --text-secondary: #5e6672;
  --text-muted: #8a929e;
  --border: #e4e7eb;
  --border-strong: #d7dce2;
  --primary: #079fc4;
  --primary-hover: #0789aa;
  --primary-soft: #e9f7fa;
  --healthy: #12bf6d;
  --healthy-soft: #e9f8f0;
  --warning: #f5a009;
  --warning-soft: #fff6df;
  --danger: #f04444;
  --danger-soft: #fff0f0;
  --sidebar-width: 216px;
  --topbar-height: 76px;
  --radius: 6px;
  --shadow-dialog: 0 18px 50px rgba(27, 35, 48, 0.18);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #11151a;
  --surface: #181d23;
  --surface-subtle: #1d232a;
  --surface-hover: #222a32;
  --text: #edf1f5;
  --text-secondary: #adb6c0;
  --text-muted: #7f8995;
  --border: #2b333c;
  --border-strong: #3a444f;
  --primary: #21b5d6;
  --primary-hover: #43c5e0;
  --primary-soft: #17323a;
  --healthy-soft: #173427;
  --warning-soft: #392f18;
  --danger-soft: #3a2022;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  letter-spacing: 0;
}

button, input, select, textarea { font: inherit; letter-spacing: 0; }

button { color: inherit; }

button, select { cursor: pointer; }

button:disabled, input:disabled, select:disabled { cursor: not-allowed; opacity: 0.55; }

input, select, textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

textarea { padding-top: 10px; resize: vertical; }

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent);
}

input::placeholder { color: var(--text-muted); }

h1, h2, h3, p { margin: 0; }

h1 { font-size: 24px; line-height: 1.2; font-weight: 720; }
h2 { font-size: 18px; line-height: 1.3; font-weight: 700; }
h3 { font-size: 15px; line-height: 1.3; font-weight: 680; }

svg { display: block; }

.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  transition: width 180ms ease, transform 180ms ease;
}

.sidebar-brand {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.sidebar-brand strong { font-size: 18px; font-weight: 760; }

.brand-icon {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

.brand-icon svg { width: 25px; height: 25px; stroke-width: 2.2; }

.icon-btn.sidebar-close { display: none; margin-left: auto; }

.sidebar-nav { flex: 1; padding: 22px 10px; overflow-y: auto; }

.nav-label {
  display: block;
  padding: 24px 14px 8px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.nav-link {
  position: relative;
  width: 100%;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  font-weight: 580;
  text-align: left;
}

.nav-link svg { width: 20px; height: 20px; flex: 0 0 auto; stroke-width: 1.9; }
.nav-link:hover { background: var(--surface-hover); }
.nav-link.active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.nav-count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: var(--danger); color: #fff; font-size: 11px; }
.sidebar-footer { padding: 10px; border-top: 1px solid var(--border); }

.main-shell { min-height: 100vh; margin-left: var(--sidebar-width); transition: margin-left 180ms ease; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-height);
  display: grid;
  grid-template-columns: minmax(190px, 0.8fr) minmax(280px, 460px) minmax(360px, 1fr);
  align-items: center;
  gap: 28px;
  padding: 0 28px;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.topbar-title-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }
.icon-btn.mobile-menu { display: none; }

.global-search { position: relative; display: block; }
.global-search svg { position: absolute; left: 14px; top: 50%; width: 20px; height: 20px; transform: translateY(-50%); color: var(--text-secondary); }
.global-search input { height: 44px; padding-left: 46px; font-size: 15px; background: var(--surface); }

.topbar-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; min-width: 0; }

.connection-badge {
  height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  white-space: nowrap;
}

.content-shell { padding: 24px 28px 42px; }

.view { width: 100%; max-width: 1720px; margin: 0 auto; }

.page-heading { min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  min-height: 108px;
  margin: -24px -28px 24px;
  padding: 18px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.metric-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
}

.metric-item:not(:last-child)::after { content: ""; position: absolute; right: 0; width: 1px; height: 48px; background: var(--border); }
.metric-label { color: var(--text-secondary); font-size: 14px; font-weight: 620; }
.metric-value { max-width: 100%; overflow: hidden; text-overflow: ellipsis; font-size: 28px; line-height: 1; font-weight: 760; font-variant-numeric: tabular-nums; white-space: nowrap; }
.metric-value.danger { color: var(--danger); }

.filter-row {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.filter-row.compact { justify-content: flex-start; }
.filter-actions, .inline-filters, .button-group { display: flex; align-items: center; gap: 10px; }

.consumption-board { margin-bottom: 22px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.consumption-board-head { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.consumption-board-head p { margin-top: 4px; }
.compact-segments button { height: 36px; padding: 0 13px; }
.consumption-grid { display: grid; grid-template-columns: minmax(300px, .78fr) minmax(420px, 1.22fr); }
.consumption-pane { min-width: 0; padding: 16px; }
.consumption-pane + .consumption-pane { border-left: 1px solid var(--border); }
.consumption-pane-title, .consumption-detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.consumption-ranking { display: grid; gap: 6px; }
.consumption-rank-row { width: 100%; display: grid; grid-template-columns: minmax(90px, 130px) minmax(72px, 1fr) auto; align-items: center; gap: 5px 10px; padding: 8px; border: 1px solid transparent; border-radius: var(--radius); background: transparent; text-align: left; }
.consumption-rank-row:hover { background: var(--surface-hover); }
.consumption-rank-row.active { border-color: var(--primary); background: var(--primary-soft); }
.consumption-rank-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.consumption-rank-row strong { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.consumption-rank-row small { grid-column: 2 / -1; color: var(--text-muted); text-align: right; }
.consumption-track { height: 8px; border-radius: 3px; background: var(--surface-subtle); overflow: hidden; }
.consumption-track i { display: block; height: 100%; border-radius: inherit; background: var(--primary); }
.consumption-detail-head .muted { display: block; margin-top: 4px; }
.chart-table-toggle { flex: none; padding: 5px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text-secondary); font-size: 12px; font-weight: 600; }
.chart-table-toggle:hover { border-color: var(--primary); color: var(--primary); }
.consumption-stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.consumption-stat span { display: block; color: var(--text-muted); font-size: 11px; }
.consumption-stat strong { display: block; margin-top: 3px; font-size: 15px; font-variant-numeric: tabular-nums; }
.consumption-stat.hero strong { font-size: 26px; font-variant-numeric: normal; letter-spacing: -.01em; }
.consumption-stat strong.warning { color: var(--warning); }
.consumption-stat strong.danger { color: var(--danger); }
.consumption-stat-note { display: block; margin-top: 2px; color: var(--text-muted); font-size: 11px; line-height: 1.35; }
.consumption-chart-wrap { min-width: 0; --series-balance: #2a78d6; --series-consumption: #eb6834; }
:root[data-theme="dark"] .consumption-chart-wrap { --series-balance: #3987e5; --series-consumption: #d95926; }
.chart-legend-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 8px; color: var(--text-secondary); font-size: 12px; }
.chart-key { display: inline-flex; align-items: center; gap: 6px; }
.chart-key i { display: block; }
.balance-key i { width: 12px; height: 2px; border-radius: 1px; background: var(--series-balance); }
.consumption-key i { width: 9px; height: 9px; border-radius: 2px; background: var(--series-consumption); }
.recharge-key i { width: 2px; height: 11px; background: var(--healthy); }
.chart-peak { margin-left: auto; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.chart-plot { position: relative; }
.consumption-chart { display: block; width: 100%; height: auto; }
.chart-gridline { stroke: var(--border); stroke-width: 1; }
.consumption-bar { fill: var(--series-consumption); }
.balance-line { fill: none; stroke: var(--series-balance); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.balance-point, .balance-end-dot { fill: var(--series-balance); }
.balance-end-ring { fill: var(--surface); }
.recharge-mark { stroke: var(--healthy); stroke-width: 1; opacity: .55; vector-effect: non-scaling-stroke; }
.chart-axis-label { fill: var(--text-muted); font-size: 11px; }
.chart-y-label { text-anchor: end; }
.chart-time-label { text-anchor: middle; }
.chart-hit { fill: transparent; outline: none; }
.chart-hit:hover, .chart-hit.active { fill: var(--text); fill-opacity: .05; }
.chart-hit:focus-visible { stroke: var(--primary); stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart-tooltip { position: absolute; top: 8px; transform: translateX(-50%); min-width: 116px; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-dialog); pointer-events: none; }
.chart-tooltip-time { margin-bottom: 5px; color: var(--text-muted); font-size: 11px; }
.chart-tooltip-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.chart-tooltip-row + .chart-tooltip-row { margin-top: 2px; }
.chart-tooltip-row strong { order: 2; font-size: 13px; font-variant-numeric: tabular-nums; }
.chart-tooltip-row span { display: inline-flex; align-items: center; gap: 5px; color: var(--text-secondary); font-size: 12px; }
.chart-tooltip-row span::before { content: ''; width: 8px; height: 8px; border-radius: 2px; background: var(--text-muted); }
.chart-tooltip-row.balance span::before { width: 10px; height: 2px; border-radius: 1px; background: var(--series-balance); }
.chart-tooltip-row.consumption span::before { background: var(--series-consumption); }
.chart-tooltip-row.recharge span::before { width: 2px; height: 10px; border-radius: 0; background: var(--healthy); }
.chart-table-wrap { max-height: 258px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.chart-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.chart-table th, .chart-table td { padding: 6px 10px; text-align: right; font-variant-numeric: tabular-nums; }
.chart-table thead th { position: sticky; top: 0; background: var(--surface-subtle); color: var(--text-secondary); font-weight: 600; }
.chart-table tbody th { text-align: left; font-weight: 600; }
.chart-table tbody tr + tr th, .chart-table tbody tr + tr td { border-top: 1px solid var(--border); }
.legend-line { width: 16px; height: 3px; background: var(--primary); }
.legend-bar { width: 11px; height: 8px; background: var(--warning); opacity: .65; }
.compact-empty { min-height: 170px; }
.consumption-cell strong { white-space: nowrap; }

.pushplus-manager { display: block; }
.pushplus-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: -2px 0 16px; }
.pushplus-table-scroll { border: 1px solid var(--border); border-radius: var(--radius); }
.pushplus-target-table { min-width: 680px; }
.pushplus-target-table > thead th:first-child { width: 34%; }
.pushplus-target-table > thead th:nth-child(2) { width: 27%; }
.pushplus-target-table > thead th:nth-child(3) { width: 18%; }
.pushplus-target-table .is-disabled > td { color: var(--text-muted); background: var(--surface-subtle); }
.pushplus-token-mask { color: var(--text-secondary); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.pushplus-editor { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.pushplus-editor-heading { margin-bottom: 14px; }
.pushplus-editor-heading .muted { margin-top: 5px; font-size: 12px; }
.pushplus-editor-grid { display: grid; grid-template-columns: minmax(180px, 0.7fr) minmax(250px, 1fr) minmax(150px, auto); align-items: end; gap: 14px; }
.pushplus-enabled-toggle { padding-bottom: 1px; }
.pushplus-editor-actions { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.pushplus-test-feedback { margin: 14px 0 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-subtle); color: var(--text-secondary); line-height: 1.55; overflow-wrap: anywhere; }
.pushplus-test-feedback.success { border-color: color-mix(in srgb, var(--healthy) 45%, var(--border)); color: var(--healthy); background: var(--healthy-soft); }
.pushplus-test-feedback.error { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); color: var(--danger); background: var(--danger-soft); }
.filter-actions select { width: 170px; }
.inline-filters select { width: 180px; }
.usage-filter-grid { display: grid; grid-template-columns: minmax(180px, 1.3fr) repeat(6, minmax(130px, 1fr)) auto; align-items: end; gap: 10px; margin-bottom: 18px; }
.usage-filter-grid label { min-width: 0; display: grid; gap: 6px; }
.usage-filter-grid label span { color: var(--text-secondary); font-size: 11px; font-weight: 650; }
.usage-filter-grid .btn { height: 40px; }

.segment-control { display: inline-flex; align-items: stretch; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.segment-control button { height: 44px; display: inline-flex; align-items: center; gap: 8px; padding: 0 18px; border: 0; border-right: 1px solid var(--border); background: transparent; white-space: nowrap; }
.segment-control button:last-child { border-right: 0; }
.segment-control button:hover { background: var(--surface-hover); }
.segment-control button.active { color: var(--primary); background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }
.segment-control strong { color: var(--text); font-variant-numeric: tabular-nums; }

.status-dot { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 50%; background: var(--text-muted); }
.status-dot.healthy { background: var(--healthy); }
.status-dot.warning { background: var(--warning); }
.status-dot.danger { background: var(--danger); }
.status-dot.neutral { background: var(--text-muted); }

.table-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table-section.spaced { margin-top: 20px; }
.table-section-title { min-height: 48px; display: flex; align-items: center; justify-content: space-between; padding: 0 4px 12px; background: var(--bg); }
.table-scroll { width: 100%; overflow-x: auto; }

.data-table { width: 100%; border-collapse: collapse; table-layout: auto; }
.data-table th, .data-table td { padding: 14px 16px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.data-table th { height: 46px; padding-top: 10px; padding-bottom: 10px; background: var(--surface-subtle); color: var(--text-secondary); font-size: 12px; font-weight: 700; white-space: nowrap; }
.data-table tbody tr:last-child > td { border-bottom: 0; }
.data-table tbody > tr.data-row:hover > td { background: var(--surface-hover); }
.data-table .align-right { text-align: right; }

.upstream-table { min-width: 1380px; table-layout: fixed; }
.upstream-table > thead th:first-child { width: 19%; }
.upstream-table > thead th:nth-child(2) { width: 11%; }
.upstream-table > thead th:nth-child(3) { width: 10%; }
.upstream-table > thead th:nth-child(4) { width: 11%; }
.upstream-table > thead th:nth-child(5) { width: 9%; }
.upstream-table > thead th:nth-child(6) { width: 10%; }
.upstream-table > thead th:nth-child(7) { width: 7%; }
.upstream-table > thead th:nth-child(8) { width: 7%; }
.upstream-table > thead th:nth-child(9) { width: 10%; }
.upstream-table > thead th:last-child { width: 140px; position: sticky; right: 0; z-index: 4; padding-left: 6px; padding-right: 6px; background: var(--surface-subtle); }
.upstream-table > tbody > tr.data-row > td:last-child { position: sticky; right: 0; z-index: 2; padding-left: 6px; padding-right: 6px; background: var(--surface); }
.upstream-table > tbody > tr.data-row:hover > td:last-child { background: var(--surface-hover); }

.upstream-name-cell { display: flex; align-items: center; gap: 12px; min-width: 210px; }
.row-chevron { width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; padding: 0; }
.row-chevron svg { width: 19px; height: 19px; transition: transform 140ms ease; }
.row-chevron.expanded svg { transform: rotate(90deg); }
.upstream-identity { min-width: 0; }
.upstream-identity strong { display: block; font-size: 15px; font-weight: 720; }
.upstream-identity small, .cell-stack small { display: block; margin-top: 4px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upstream-name-link { display: block; max-width: 100%; padding: 0; border: 0; background: none; color: var(--text); font: inherit; font-size: 15px; font-weight: 720; text-align: left; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upstream-name-link:hover { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }
.upstream-name-link:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
.upstream-url-link { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; margin-top: 4px; color: var(--text-muted); font-size: 12px; text-decoration: none; }
.upstream-url-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upstream-url-link i { flex: none; width: 12px; height: 12px; opacity: .65; }
.upstream-url-link:hover { color: var(--primary); }
.upstream-url-link:hover i { opacity: 1; }
.upstream-url-link:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
#detailSubtitle { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.detail-site-link { display: inline-flex; align-items: center; gap: 4px; color: var(--text-secondary); text-decoration: none; }
.detail-site-link:hover { color: var(--primary); }
.detail-site-link i { width: 12px; height: 12px; opacity: .65; }
.detail-username { display: inline-flex; align-items: center; gap: 4px; color: var(--text-secondary); }
.detail-username i { width: 13px; height: 13px; opacity: .7; }
.cell-stack { min-width: 0; max-width: 100%; }
.sync-cell { width: 100%; }
.sync-error { max-width: 100%; cursor: help; }

.balance-value { display: block; font-size: 24px; line-height: 1; font-weight: 780; font-variant-numeric: tabular-nums; white-space: nowrap; }
.balance-value.low { color: var(--danger); }
.balance-meta { display: block; margin-top: 5px; color: var(--text-muted); font-size: 11px; white-space: nowrap; }
.numeric { font-variant-numeric: tabular-nums; }
.danger-text { color: var(--danger) !important; }
.warning-text { color: var(--warning) !important; }
.healthy-text { color: var(--healthy) !important; }

.status-label { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.status-pill { display: inline-flex; align-items: center; gap: 7px; min-height: 28px; padding: 0 9px; border-radius: 14px; font-size: 12px; font-weight: 650; background: var(--surface-subtle); }
.status-pill.healthy { color: #067e46; background: var(--healthy-soft); }
.status-pill.warning { color: #9a6100; background: var(--warning-soft); }
.status-pill.danger { color: #c92929; background: var(--danger-soft); }
.status-pill.neutral { color: var(--text-secondary); }

.row-actions { display: inline-flex; align-items: center; justify-content: flex-end; gap: 3px; min-width: 88px; }
.icon-btn { width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; padding: 0; border: 0; border-radius: var(--radius); background: transparent; }
.icon-btn:hover { background: var(--surface-hover); }
.icon-btn.bordered { border: 1px solid var(--border-strong); background: var(--surface); }
.icon-btn svg { width: 19px; height: 19px; stroke-width: 1.9; }
.upstream-row-actions { min-width: 126px; gap: 2px; }
.upstream-row-actions .icon-btn { width: 30px; height: 30px; border-radius: 4px; }
.upstream-row-actions .icon-btn svg { width: 16px; height: 16px; }

.btn { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 15px; border: 1px solid transparent; border-radius: var(--radius); font-weight: 650; white-space: nowrap; }
.btn svg { width: 17px; height: 17px; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.secondary { background: var(--surface); border-color: var(--border-strong); }
.btn.secondary:hover { background: var(--surface-hover); }
.btn.danger-outline { color: var(--danger); background: transparent; border-color: color-mix(in srgb, var(--danger) 42%, var(--border)); }
.btn.full { width: 100%; }
.text-btn { border: 0; padding: 4px; background: transparent; color: var(--primary); }

.expanded-row > td { padding: 0 16px 16px !important; background: var(--surface); }
.expanded-panel { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-subtle); overflow: hidden; }
.expanded-header { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 20px; }
.expanded-header strong { font-size: 15px; }
.expanded-title small { display: block; margin-top: 5px; color: var(--text-muted); }
.expanded-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.key-inner-wrap { margin: 0 20px 18px; border: 1px solid var(--border); border-radius: 4px; overflow-x: auto; background: var(--surface); }
.key-inner-table { min-width: 1160px; }
.key-inner-table th, .key-inner-table td { padding: 11px 14px; }
.key-inner-table .failure-row td { background: var(--danger-soft); }
.key-model-select { min-width: 178px; min-height: 34px; height: 34px; padding: 0 28px 0 9px; font-size: 12px; }
.key-name { font-weight: 650; white-space: nowrap; }
.key-code { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.key-code code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.copy-mini { width: 25px; height: 25px; }
.copy-mini svg { width: 15px; height: 15px; }
.usage-table { min-width: 1120px; }
.usage-table td { font-size: 13px; }
.usage-token-cell { display: grid; gap: 3px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.usage-token-cell small { color: var(--text-muted); }
.pagination-bar { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--border); color: var(--text-secondary); }

.surface { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.surface-title { min-height: 52px; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; border-bottom: 1px solid var(--border); }
.overview-grid, .log-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.event-list { padding: 6px 18px; }
.event-list.dense { max-height: 680px; overflow-y: auto; }
.event-item { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--border); }
.event-item:last-child { border-bottom: 0; }
.event-main { min-width: 0; }
.event-main strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-main small { display: block; margin-top: 5px; color: var(--text-muted); overflow-wrap: anywhere; }
.empty-state { min-height: 120px; display: flex; align-items: center; justify-content: center; padding: 20px; color: var(--text-muted); text-align: center; }

.pricing-board { display: grid; gap: 10px; }
.rate-board-summary { color: var(--text-muted); font-size: 12px; }
.rate-site { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.rate-site.expanded { border-color: var(--border-strong); }
.rate-site-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; }
.rate-site-head:hover { background: var(--surface-hover); }
.rate-site-toggle { flex: none; display: inline-flex; padding: 0; background: none; border: 0; cursor: pointer; color: var(--text-muted); }
.rate-site-link.plain { color: var(--text); }
.rate-site-main { display: flex; align-items: baseline; gap: 10px; flex: 1; min-width: 0; }
.rate-site-main > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rate-site-link { color: var(--primary); font-weight: 600; text-decoration: none; }
.rate-site-link:hover { text-decoration: underline; }
.rate-badge { flex: none; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rate-badge.good { background: var(--healthy-soft); color: var(--healthy); }
.rate-badge.normal { background: var(--primary-soft); color: var(--primary); }
.rate-badge.high { background: var(--warning-soft); color: var(--warning); }
.rate-badge.muted { background: var(--surface-subtle); color: var(--text-muted); }
.rate-group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.rate-group-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 12px 14px; }
.rate-group-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.rate-group-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rate-detail-list { display: grid; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.rate-detail-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; font-size: 12px; }
.rate-detail-line strong { font-variant-numeric: tabular-nums; }
.rate-empty { color: var(--text-muted); font-size: 12px; }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.setting-section { min-height: 100px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px; }
.setting-section .muted { margin-top: 6px; }
.setting-form-section { grid-column: 1 / -1; }
.setting-inline-form { width: min(980px, 100%); display: grid; grid-template-columns: minmax(160px, 0.7fr) minmax(220px, 1fr) auto; align-items: center; gap: 12px; }
.setting-inline-form label { min-width: 0; }
.settings-tabs { margin-bottom: 18px; }
.settings-panel { display: grid; gap: 16px; }
.runtime-setting-section { padding: 20px; }
.section-heading { min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.section-heading .muted { margin-top: 5px; font-size: 12px; }
.settings-form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.settings-form-grid.compact-grid { grid-template-columns: repeat(3, minmax(160px, 1fr)); align-items: end; }
.setting-field { min-width: 0; display: grid; gap: 7px; }
.setting-field > span { color: var(--text-secondary); font-size: 12px; font-weight: 650; }
.password-save-field { align-content: end; }
.setting-spacer { min-height: 12px; }
.toggle-grid { display: grid; grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 10px; margin-bottom: 18px; }
.toggle-field { position: relative; min-height: 40px; display: inline-flex; align-items: center; gap: 10px; color: var(--text-secondary); font-size: 13px; font-weight: 620; cursor: pointer; }
.toggle-field input { position: absolute; width: 1px; min-height: 1px; opacity: 0; pointer-events: none; }
.toggle-control { position: relative; width: 38px; height: 22px; flex: 0 0 auto; border: 1px solid var(--border-strong); border-radius: 11px; background: var(--surface-subtle); transition: background 140ms ease, border-color 140ms ease; }
.toggle-control::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--text-muted); transition: transform 140ms ease, background 140ms ease; }
.toggle-field input:checked + .toggle-control { border-color: var(--primary); background: var(--primary); }
.toggle-field input:checked + .toggle-control::after { transform: translateX(16px); background: #fff; }
.toggle-field input:focus-visible + .toggle-control { box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.toggle-field input:disabled + .toggle-control { opacity: 0.5; cursor: not-allowed; }
.inline-toggle { padding-bottom: 1px; }
.compact-toggle { min-height: 32px; }
.maintenance-grid { margin-top: 0; }
.version-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.version-grid > div { min-width: 0; display: grid; gap: 7px; padding: 16px; border-right: 1px solid var(--border); }
.version-grid > div:last-child { border-right: 0; }
.version-grid span { color: var(--text-muted); font-size: 12px; }
.version-grid strong { font-size: 18px; }
.version-grid code, .version-grid small { color: var(--text-secondary); overflow-wrap: anywhere; }
.update-commit-list { margin-top: 14px; border-top: 1px solid var(--border); }
.update-commit-item { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.update-commit-item code { color: var(--text-muted); }
.update-error { margin-top: 14px; padding: 11px 12px; border-left: 3px solid var(--danger); color: var(--danger); background: color-mix(in srgb, var(--danger) 7%, transparent); white-space: pre-wrap; overflow-wrap: anywhere; }
.update-actions { display: flex; justify-content: flex-end; margin-top: 16px; }
.settings-policy-table { min-width: 1180px; }
.settings-policy-table input[type="number"] { width: 116px; min-height: 34px; }
.policy-control { display: flex; align-items: center; gap: 8px; }
.policy-number { width: 110px !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.muted { color: var(--text-muted); }

.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-box { width: min(380px, 100%); display: grid; gap: 18px; padding: 30px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-dialog); }
.login-box .brand-mark { width: 44px; height: 44px; display: grid; place-items: center; border-radius: var(--radius); color: #fff; background: var(--primary); }
.login-box label, .modal-body > label, .form-grid label { display: grid; gap: 7px; }
.login-box label span, .modal-body label span, .form-grid label span { color: var(--text-secondary); font-size: 12px; font-weight: 650; }
.form-message { min-height: 18px; color: var(--text-secondary); font-size: 12px; }
.form-message.error { color: var(--danger); }
.form-message.success { color: var(--healthy); }
.form-subsection { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.form-subsection-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.form-subsection-head .muted { margin-top: 4px; font-size: 12px; }
.probe-model-list { display: grid; gap: 8px; }
.probe-model-row { min-height: 58px; display: grid; grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.2fr) auto; align-items: center; gap: 12px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); }
.probe-model-meta { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.probe-model-meta small { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.probe-model-source { color: var(--text-secondary); font-size: 12px; white-space: nowrap; }

dialog { color: var(--text); }
dialog::backdrop { background: rgba(13, 18, 24, 0.44); backdrop-filter: blur(2px); }
.modal { width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 40px); padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-dialog); }
.small-modal { width: min(480px, calc(100vw - 32px)); }
.modal-body { display: grid; gap: 16px; padding: 22px; }
.modal-header { min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.modal-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding-top: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.form-grid .span-2 { grid-column: span 2; }

.drawer-dialog { width: min(720px, 92vw); max-width: none; height: 100vh; max-height: none; margin: 0 0 0 auto; padding: 0; border: 0; border-left: 1px solid var(--border); background: var(--surface); }
.drawer-shell { height: 100%; display: grid; grid-template-rows: auto 1fr; }
.drawer-shell > .modal-header { min-height: 76px; padding: 0 22px; border-bottom: 1px solid var(--border); }
.drawer-content { padding: 22px; overflow-y: auto; }
.detail-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.detail-metric { padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-subtle); }
.detail-metric span { color: var(--text-muted); font-size: 11px; }
.detail-metric strong { display: block; margin-top: 8px; font-size: 20px; font-variant-numeric: tabular-nums; }
.detail-block { margin-top: 22px; }
.detail-block h3 { margin-bottom: 10px; }
.detail-list { display: grid; gap: 8px; }
.detail-line { display: flex; justify-content: space-between; gap: 18px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.detail-line span { color: var(--text-secondary); }

.secret-box { min-height: 52px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; padding: 8px 10px 8px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface-subtle); }
.secret-box code { overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.toast-region { position: fixed; z-index: 100; right: 22px; bottom: 22px; display: grid; gap: 9px; width: min(380px, calc(100vw - 44px)); }
.toast { display: grid; grid-template-columns: auto 1fr auto; align-items: start; gap: 10px; padding: 13px 14px; border: 1px solid var(--border); border-left: 3px solid var(--primary); border-radius: var(--radius); background: var(--surface); box-shadow: 0 10px 28px rgba(20, 28, 38, 0.16); }
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--healthy); }
.toast button { border: 0; background: transparent; padding: 0; color: var(--text-muted); }

.loading-overlay { position: fixed; z-index: 90; inset: 0; display: grid; place-items: center; background: rgba(255, 255, 255, 0.28); pointer-events: none; }
:root[data-theme="dark"] .loading-overlay { background: rgba(0, 0, 0, 0.22); }
.spinner { width: 34px; height: 34px; border: 3px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.sidebar-collapsed .sidebar { width: 72px; }
.sidebar-collapsed .sidebar-brand { padding: 0 21px; }
.sidebar-collapsed .sidebar-brand strong, .sidebar-collapsed .nav-link span:not(.nav-count), .sidebar-collapsed .nav-label { display: none; }
.sidebar-collapsed .nav-link { justify-content: center; padding: 0; }
.sidebar-collapsed .main-shell { margin-left: 72px; }
.sidebar-collapsed .sidebar-footer svg { transform: rotate(180deg); }

@media (max-width: 1180px) {
  .topbar { grid-template-columns: minmax(170px, 0.7fr) minmax(240px, 1fr) auto; gap: 16px; padding: 0 20px; }
  .connection-badge span:last-child { display: none; }
  .content-shell { padding-left: 20px; padding-right: 20px; }
  .metric-strip { margin-left: -20px; margin-right: -20px; padding-left: 20px; padding-right: 20px; }
  .pricing-board { grid-template-columns: 1fr; }
  .usage-filter-grid { grid-template-columns: repeat(4, minmax(140px, 1fr)); }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); width: min(300px, 84vw); box-shadow: var(--shadow-dialog); }
  .sidebar.open { transform: translateX(0); }
  .icon-btn.sidebar-close, .icon-btn.mobile-menu { display: inline-flex; }
  .main-shell, .sidebar-collapsed .main-shell { margin-left: 0; }
  .topbar { grid-template-columns: 1fr auto; height: auto; min-height: 72px; padding: 12px 16px; }
  .global-search { grid-column: 1 / -1; grid-row: 2; }
  .topbar-actions { grid-column: 2; grid-row: 1; }
  .topbar-actions .connection-badge { display: none; }
  .content-shell { padding: 18px 16px 32px; }
  .metric-strip { margin: -18px -16px 18px; padding: 14px 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-item { min-height: 72px; }
  .metric-item:nth-child(2)::after { display: none; }
  .metric-item:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
  .filter-row { align-items: stretch; flex-direction: column; }
  .segment-control { width: 100%; overflow-x: auto; }
  .segment-control button { flex: 1 0 auto; }
  .filter-actions { justify-content: space-between; }
  .overview-grid, .log-layout, .settings-grid { grid-template-columns: 1fr; }
  .consumption-grid { grid-template-columns: 1fr; }
  .consumption-pane + .consumption-pane { border-left: 0; border-top: 1px solid var(--border); }
  .drawer-dialog { width: min(680px, 100vw); }
}

@media (max-width: 620px) {
  h1 { font-size: 20px; }
  .topbar-actions .btn span { display: none; }
  .topbar-actions .btn { width: 40px; padding: 0; }
  .metric-value { font-size: 23px; }
  .filter-actions { flex-wrap: wrap; }
  .consumption-board-head { align-items: stretch; flex-direction: column; }
  .compact-segments { width: 100%; }
  .compact-segments button { flex: 1; padding-left: 8px; padding-right: 8px; }
  .consumption-rank-row { grid-template-columns: minmax(86px, 110px) minmax(60px, 1fr) auto; }
  .consumption-stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-actions select, .filter-actions .btn { flex: 1; width: auto; }
  .inline-filters { width: 100%; flex-direction: column; }
  .inline-filters select { width: 100%; }
  .expanded-header { align-items: flex-start; flex-direction: column; padding-top: 16px; padding-bottom: 16px; }
  .expanded-actions { width: 100%; }
  .expanded-actions .btn { flex: 1; }
  .key-inner-wrap { margin-left: 10px; margin-right: 10px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .detail-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .setting-section { align-items: flex-start; flex-direction: column; }
  .setting-inline-form { width: 100%; grid-template-columns: 1fr; }
  .pushplus-editor-grid { grid-template-columns: 1fr; }
  .pushplus-editor-actions .btn { flex: 1; }
  [data-view="alerts"] .page-heading { align-items: stretch; flex-direction: column; }
  [data-view="alerts"] .filter-actions { width: 100%; }
  [data-view="settings"] .page-heading { align-items: stretch; flex-direction: column; }
  [data-view="settings"] .page-heading .btn { width: 100%; }
  .settings-tabs { width: 100%; overflow-x: auto; }
  .settings-tabs button { flex: 1 0 auto; }
  .settings-form-grid, .settings-form-grid.compact-grid, .toggle-grid { grid-template-columns: 1fr; }
  .version-grid { grid-template-columns: 1fr; }
  .version-grid > div { border-right: 0; border-bottom: 1px solid var(--border); }
  .version-grid > div:last-child { border-bottom: 0; }
  .update-actions .btn { width: 100%; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .probe-model-row { grid-template-columns: 1fr; align-items: stretch; }
  .usage-filter-grid { grid-template-columns: 1fr 1fr; }
  .usage-filter-grid label:first-child, .usage-filter-grid .btn { grid-column: 1 / -1; }
  .pagination-bar { align-items: stretch; flex-direction: column; }
  .pagination-bar .button-group .btn { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
.key-probe-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.key-probe-schedule {
  flex: 0 0 auto;
}
