:root {
  --bg: #F7F8FA;
  --surface: #FFFFFF;
  --fg: #1F2937;
  --muted: #667085;
  --subtle: #98A2B3;
  --border: #E5E7EB;
  --accent: #3A7DF0;
  --success: #16A34A;
  --warning: #F59E0B;
  --danger: #EF4444;
  --sidebar-width: 232px;
  --topbar-height: 56px;
  --radius: 8px;
  --font-sans: Inter, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --shadow-popover: 0 12px 28px color-mix(in srgb, var(--fg) 12%, transparent);
}

* { box-sizing: border-box; }
html, body { min-width: 1280px; min-height: 100%; }
body { margin: 0; color: var(--fg); background: var(--bg); font: 14px/1.5 var(--font-sans); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button { color: inherit; }
h1, h2, h3, p { text-wrap: pretty; }
button:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 28%, transparent); outline-offset: 2px; }
.icon { width: 18px; height: 18px; flex: 0 0 auto; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 16px; height: 16px; }
.mono { font-family: var(--font-mono); }
.app-shell { min-height: 100vh; }

.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; width: var(--sidebar-width); overflow: hidden; background: var(--surface); border-right: 1px solid var(--border); transition: width 180ms ease; }
.brand { height: var(--topbar-height); display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.brand-mark { width: 28px; height: 28px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 7px; color: var(--surface); background: var(--accent); font-weight: 700; letter-spacing: -1px; }
.brand-copy { min-width: 0; transition: opacity 120ms ease; }
.brand-title { font-size: 15px; font-weight: 600; line-height: 20px; }
.brand-subtitle { color: var(--muted); font-size: 11px; line-height: 16px; }
.nav-wrap { padding: 16px 12px; }
.nav-label { margin: 0 10px 8px; color: var(--subtle); font-size: 12px; white-space: nowrap; }
.nav-list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.nav-item { width: 100%; height: 44px; display: flex; align-items: center; gap: 12px; padding: 0 12px; color: var(--muted); border: 0; border-radius: var(--radius); background: transparent; cursor: pointer; white-space: nowrap; text-decoration: none; transition: color 160ms ease, background 160ms ease; }
.nav-item:hover { color: var(--fg); background: var(--bg); }
.nav-item.active { color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); font-weight: 600; }
.nav-text { transition: opacity 120ms ease; }
.sidebar-footer { position: absolute; inset: auto 12px 16px; }
.collapse-button { width: 100%; height: 40px; display: flex; align-items: center; gap: 12px; padding: 0 12px; color: var(--muted); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; }
.collapse-button:hover { color: var(--fg); background: var(--bg); }

.topbar { position: fixed; z-index: 20; left: var(--sidebar-width); right: 0; top: 0; height: var(--topbar-height); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; background: color-mix(in srgb, var(--surface) 96%, transparent); border-bottom: 1px solid var(--border); transition: left 180ms ease; }
.breadcrumb { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb strong { color: var(--fg); font-weight: 500; }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.environment { height: 32px; display: flex; align-items: center; gap: 7px; padding: 0 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); cursor: pointer; }
.environment-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.icon-button { width: 40px; height: 40px; display: grid; place-items: center; position: relative; color: var(--muted); border: 0; border-radius: var(--radius); background: transparent; cursor: pointer; }
.icon-button:hover, .avatar-button:hover { color: var(--fg); background: var(--bg); }
.notify-dot { position: absolute; top: 9px; right: 9px; width: 7px; height: 7px; background: var(--danger); border: 2px solid var(--surface); border-radius: 50%; }
.divider { width: 1px; height: 24px; margin: 0 4px; background: var(--border); }
.avatar-button { height: 40px; display: flex; align-items: center; gap: 9px; padding: 0 6px 0 8px; border: 0; border-radius: var(--radius); background: transparent; cursor: pointer; }
.avatar { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; color: var(--surface); background: var(--fg); font-size: 12px; font-weight: 600; }
.avatar-name { display: block; font-size: 13px; font-weight: 500; line-height: 18px; }
.avatar-role { display: block; color: var(--muted); font-size: 11px; line-height: 14px; }

.content { min-height: 100vh; margin-left: var(--sidebar-width); padding-top: var(--topbar-height); transition: margin-left 180ms ease; }
.content-inner { display: grid; gap: 16px; padding: 24px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 8px; }
.page-heading h1 { margin: 0 0 4px; font-size: 24px; line-height: 34px; font-weight: 600; letter-spacing: -.02em; }
.page-heading p { margin: 0; color: var(--muted); }
.page-identity { display: flex; align-items: flex-start; gap: 12px; }
.back-button { width: 36px; height: 36px; display: grid; place-items: center; margin-top: 1px; color: var(--muted); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; }
.back-button:hover { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }
.identity-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 7px; color: var(--muted); font-size: 12px; }
.header-actions { display: flex; align-items: center; gap: 8px; }

.button { min-height: 36px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); font-weight: 500; cursor: pointer; transition: background 160ms ease, border-color 160ms ease, transform 100ms ease; }
.button:hover { background: var(--bg); border-color: color-mix(in srgb, var(--fg) 20%, var(--border)); }
.button:active { transform: translateY(1px); }
.button-primary { color: var(--surface); background: var(--accent); border-color: var(--accent); box-shadow: 0 1px 2px color-mix(in srgb, var(--accent) 28%, transparent); }
.button-primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--fg)); border-color: color-mix(in srgb, var(--accent) 88%, var(--fg)); }
.link-button { padding: 0; color: var(--accent); border: 0; background: transparent; cursor: pointer; text-decoration: none; }
.link-button:hover { text-decoration: underline; }
.select, .input { min-height: 36px; padding: 7px 10px; color: var(--fg); border: 1px solid var(--border); border-radius: 6px; background: var(--surface); outline: none; }
.select:focus, .input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card-header { min-height: 60px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 16px 18px 12px; }
.card-title { margin: 0; font-size: 16px; line-height: 24px; font-weight: 600; }
.card-desc { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.card-tools { display: flex; align-items: center; gap: 8px; }
.card-body { padding: 0 18px 18px; }
.section-stack { display: grid; gap: 16px; }
.two-col { display: grid; grid-template-columns: minmax(0,1.55fr) minmax(360px,.75fr); gap: 16px; align-items: start; }

.condition-card { padding: 14px 16px; }
.condition-primary { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.condition-label { color: var(--muted); font-size: 12px; font-weight: 500; }
.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--border); border-radius: 7px; background: var(--bg); }
.segment { min-height: 28px; padding: 0 10px; color: var(--muted); border: 0; border-radius: 5px; background: transparent; cursor: pointer; font-size: 12px; }
.segment:hover { color: var(--fg); }
.segment.active { color: var(--accent); background: var(--surface); box-shadow: 0 1px 2px color-mix(in srgb, var(--fg) 9%, transparent); font-weight: 600; }
.condition-divider { width: 1px; height: 28px; background: var(--border); }
.condition-secondary { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.filter-field label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.filter-field .select, .filter-field .input { width: 100%; }
.condition-actions { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; }
.updated-time { color: var(--subtle); font-size: 12px; }
.action-group { display: flex; gap: 8px; }

.metrics-grid { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); gap: 12px; }
.metric-card { min-width: 0; min-height: 112px; padding: 14px 15px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.metric-name { color: var(--muted); font-size: 12px; }
.metric-value { margin-top: 8px; font-size: 24px; line-height: 30px; font-weight: 600; letter-spacing: -.025em; white-space: nowrap; }
.metric-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 9px; color: var(--subtle); font-size: 11px; }
.trend-up { color: var(--success); }
.trend-down { color: var(--danger); }
.sparkline { width: 58px; height: 20px; overflow: visible; }
.sparkline path { fill: none; stroke: var(--accent); stroke-width: 1.6; vector-effect: non-scaling-stroke; }

.chart-meta { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 12px; }
.legend { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 10px; height: 3px; border-radius: 2px; background: var(--accent); }
.legend-swatch.secondary { background: var(--subtle); }
.legend-swatch.limit { background: var(--danger); }
.chart-shell { position: relative; min-height: 300px; }
.chart { width: 100%; height: 300px; }
.chart.tall { height: 340px; }
.chart.short { height: 250px; }
.fallback-chart { display: block; width: 100%; height: 100%; font: 12px Inter, system-ui, -apple-system, "Segoe UI", "PingFang SC", sans-serif; color: #667085; }
.fallback-grid line { stroke: #E5E7EB; stroke-width: 1; }
.fallback-labels, .bar-value { fill: #667085; }
.bar-label { fill: #1F2937; font-size: 12px; }
.chart-overlay { position: absolute; z-index: 3; inset: 0; display: none; align-items: center; justify-content: center; border-radius: 6px; background: color-mix(in srgb, var(--surface) 92%, transparent); }
.chart-shell.loading .chart-overlay { display: flex; }
.loader { width: 26px; height: 26px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.no-data { display: none; min-height: 240px; align-items: center; justify-content: center; text-align: center; }
.no-data.show { display: flex; }
.no-data-icon { width: 44px; height: 44px; display: grid; place-items: center; margin: 0 auto 10px; color: var(--muted); border: 1px solid var(--border); border-radius: 50%; background: var(--bg); }
.no-data-title { font-weight: 600; }
.no-data-copy { margin-top: 4px; color: var(--muted); font-size: 12px; }

.comparison-grid { display: grid; grid-template-columns: minmax(330px,.75fr) minmax(0,1.45fr); gap: 16px; }
.chart-column { min-width: 0; border: 1px solid var(--border); border-radius: 7px; padding: 12px; }
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: 7px; }
.data-table { width: 100%; min-width: 980px; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.data-table.compact { min-width: 760px; }
.data-table.wide { min-width: 1240px; }
.data-table th { height: 42px; padding: 0 10px; color: var(--muted); background: var(--bg); border-bottom: 1px solid var(--border); font-size: 11px; font-weight: 600; text-align: left; white-space: nowrap; }
.data-table td { height: 48px; padding: 7px 10px; border-bottom: 1px solid var(--border); font-size: 12px; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: color-mix(in srgb, var(--bg) 72%, var(--surface)); }
.data-table th.num, .data-table td.num { text-align: right; font-family: var(--font-mono); }
.cell-primary { font-weight: 500; }
.cell-secondary { margin-top: 2px; color: var(--muted); font-size: 11px; }
.status-badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 7px; border-radius: 5px; font-size: 11px; font-weight: 500; white-space: nowrap; }
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { color: var(--success); background: color-mix(in srgb, var(--success) 9%, var(--surface)); }
.badge-warning { color: color-mix(in srgb, var(--warning) 78%, var(--fg)); background: color-mix(in srgb, var(--warning) 10%, var(--surface)); }
.badge-warning-deep { color: color-mix(in srgb, var(--warning) 64%, var(--danger)); background: color-mix(in srgb, var(--warning) 11%, var(--surface)); }
.badge-danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); }
.badge-muted { color: var(--subtle); background: var(--bg); }
.tag { display: inline-flex; align-items: center; height: 23px; padding: 0 7px; border: 1px solid var(--border); border-radius: 5px; background: var(--bg); color: var(--muted); font-size: 11px; }

.tabs { display: flex; align-items: center; gap: 24px; min-height: 48px; padding: 0 18px; border-bottom: 1px solid var(--border); }
.tab { height: 48px; position: relative; padding: 0; color: var(--muted); border: 0; background: transparent; cursor: pointer; font-weight: 500; }
.tab:hover { color: var(--fg); }
.tab.active { color: var(--accent); }
.tab.active::after { content: ""; position: absolute; inset: auto 0 -1px; height: 2px; background: var(--accent); }
.tab-panel { display: none; padding: 16px 18px 18px; }
.tab-panel.active { display: block; }
.submetrics { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; margin-bottom: 16px; }
.submetric { padding: 12px; border: 1px solid var(--border); border-radius: 7px; background: var(--bg); }
.submetric-label { color: var(--muted); font-size: 11px; }
.submetric-value { margin-top: 5px; font-size: 19px; font-weight: 600; }
.view-switch { display: inline-flex; gap: 4px; padding: 3px; border: 1px solid var(--border); border-radius: 7px; background: var(--bg); }
.view-switch button { min-height: 28px; padding: 0 10px; color: var(--muted); border: 0; border-radius: 5px; background: transparent; cursor: pointer; font-size: 12px; }
.view-switch button.active { color: var(--accent); background: var(--surface); font-weight: 600; }
.callout { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; color: var(--muted); border: 1px solid var(--border); border-radius: 7px; background: var(--bg); font-size: 12px; }

.quota-list { display: grid; gap: 10px; }
.quota-group-title { margin: 4px 0 8px; font-size: 13px; font-weight: 600; }
.quota-row { display: grid; grid-template-columns: 126px repeat(3,1fr) 1.4fr 130px 90px; align-items: center; gap: 12px; min-height: 58px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 7px; }
.quota-label { font-weight: 600; }
.quota-item-label { color: var(--muted); font-size: 10px; }
.quota-item-value { margin-top: 2px; font: 500 12px/18px var(--font-mono); }
.progress { height: 7px; overflow: hidden; border-radius: 999px; background: var(--border); }
.progress-fill { height: 100%; border-radius: inherit; background: var(--success); }
.progress-fill.warning { background: var(--warning); }
.progress-fill.warning-deep { background: color-mix(in srgb, var(--warning) 68%, var(--danger)); }
.progress-fill.danger { background: var(--danger); }
.progress-meta { display: flex; justify-content: space-between; margin-bottom: 5px; font-size: 11px; }

.runtime-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; }
.runtime-item { padding: 12px; border: 1px solid var(--border); border-radius: 7px; background: var(--bg); }
.runtime-label { color: var(--muted); font-size: 11px; }
.runtime-value { margin-top: 4px; font: 600 18px/24px var(--font-mono); }

.toast { position: fixed; z-index: 90; left: 50%; bottom: 28px; display: flex; align-items: center; gap: 9px; padding: 10px 14px; color: var(--surface); background: var(--fg); border-radius: var(--radius); box-shadow: var(--shadow-popover); opacity: 0; pointer-events: none; transform: translate(-50%,10px); transition: opacity 180ms ease, transform 180ms ease; }
.toast.show { opacity: 1; transform: translate(-50%,0); }
.toast-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }

body.collapsed { --sidebar-width: 72px; }
body.collapsed .brand { justify-content: center; padding: 0; }
body.collapsed .brand-copy, body.collapsed .nav-label, body.collapsed .nav-text, body.collapsed .collapse-button span { opacity: 0; pointer-events: none; }
body.collapsed .nav-item, body.collapsed .collapse-button { justify-content: center; padding-inline: 0; }
body.collapsed .collapse-button .icon { transform: rotate(180deg); }

@media (max-width: 1360px) {
  .metrics-grid { gap: 8px; }
  .metric-card { padding-inline: 11px; }
  .metric-value { font-size: 21px; }
  .condition-secondary { grid-template-columns: repeat(4,minmax(0,1fr)); }
  .comparison-grid { grid-template-columns: minmax(300px,.7fr) minmax(0,1.4fr); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; } }
