:root {
    color-scheme: dark;
    --bg: oklch(0.16 0.02 255);
    --sidebar: oklch(0.19 0.023 255);
    --surface: oklch(0.22 0.024 255);
    --surface-raised: oklch(0.255 0.025 255);
    --surface-hover: oklch(0.29 0.027 255);
    --border: oklch(0.37 0.025 255);
    --border-soft: oklch(0.31 0.022 255);
    --text: oklch(0.94 0.01 255);
    --muted: oklch(0.72 0.02 255);
    --faint: oklch(0.59 0.02 255);
    --primary: oklch(0.72 0.15 205);
    --primary-hover: oklch(0.77 0.14 205);
    --success: oklch(0.74 0.15 155);
    --warning: oklch(0.80 0.14 78);
    --danger: oklch(0.68 0.18 25);
    --info: oklch(0.72 0.12 245);
    --radius: 12px;
    --shadow: 0 14px 34px oklch(0.08 0.02 255 / .22);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif; }
button, input, select, textarea { font: inherit; }
button, a, summary { -webkit-tap-highlight-color: transparent; }
a { color: var(--primary); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; line-height: 1.25; letter-spacing: -.02em; }
h2 { font-size: 18px; line-height: 1.35; }
h3 { font-size: 15px; line-height: 1.4; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.numeric { font-variant-numeric: tabular-nums; }
.code, code, pre { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.stack { display: grid; gap: 16px; }
.stack.tight { gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.align-start { align-items: flex-start; }
.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; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 24px 14px 16px; background: var(--sidebar); border-right: 1px solid var(--border-soft); z-index: 20; }
.brand-block { display: flex; align-items: center; gap: 11px; padding: 0 10px 24px; }
.brand-block strong, .brand-block span { display: block; }
.brand-block strong { font-size: 16px; }
.brand-block div > span { color: var(--muted); font-size: 12px; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; color: oklch(0.16 0.02 255); background: var(--primary); font-weight: 850; }
.menu-close { display: none; margin-left: auto; min-height: 36px; padding: 6px 9px; color: var(--muted); background: transparent; border-color: var(--border); font-size: 12px; }
.side-nav { display: grid; gap: 4px; }
.side-nav a { display: grid; gap: 1px; padding: 10px 12px; border-radius: 9px; color: var(--muted); text-decoration: none; border: 1px solid transparent; }
.side-nav a span { color: inherit; font-weight: 700; }
.side-nav a small { color: var(--faint); font-size: 12px; }
.side-nav a:hover { background: var(--surface); color: var(--text); }
.side-nav a.active { background: var(--surface-raised); border-color: var(--border); color: var(--text); }
.side-nav a.active small { color: var(--muted); }
.sidebar-account { margin-top: auto; display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 14px 8px 0; border-top: 1px solid var(--border-soft); }
.sidebar-account strong, .sidebar-account span { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sidebar-account div > span { color: var(--muted); font-size: 12px; }
.avatar { display: grid !important; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--surface-raised); color: var(--primary); font-weight: 800; }
.workspace { min-width: 0; }
.topbar { min-height: 116px; display: flex; align-items: center; gap: 16px; padding: 24px clamp(20px, 3vw, 44px); border-bottom: 1px solid var(--border-soft); }
.eyebrow { margin-bottom: 4px; color: var(--primary); font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.page-subtitle { margin-top: 5px; color: var(--muted); max-width: 72ch; }
.page-content { width: min(1480px, 100%); padding: 28px clamp(20px, 3vw, 44px) 56px; display: grid; gap: 24px; }
.menu-button { display: none; }

.panel { min-width: 0; background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 20px 22px; border-bottom: 1px solid var(--border-soft); }
.panel-header p { margin-top: 4px; color: var(--muted); max-width: 72ch; }
.panel-body { padding: 22px; }
.section-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, .8fr); gap: 20px; align-items: start; }
.split-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.metric-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.metric { padding: 19px 22px; min-width: 0; }
.metric + .metric { border-left: 1px solid var(--border-soft); }
.metric span { display: block; color: var(--muted); font-size: 13px; }
.metric strong { display: block; margin-top: 5px; font-size: 24px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.metric small { display: block; margin-top: 5px; color: var(--faint); }
.attention-list { display: grid; }
.attention-item { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 14px 0; color: var(--text); text-decoration: none; }
.attention-item + .attention-item { border-top: 1px solid var(--border-soft); }
.attention-item:hover strong { color: var(--primary); }
.attention-count { display: grid; place-items: center; min-width: 32px; height: 32px; padding: 0 8px; border-radius: 9px; background: var(--surface-raised); font-weight: 800; font-variant-numeric: tabular-nums; }
.attention-item p { color: var(--muted); font-size: 13px; }
.arrow { color: var(--faint); font-size: 18px; }

.chart { display: grid; gap: 14px; }
.chart-row { display: grid; grid-template-columns: 72px minmax(120px, 1fr) 76px; align-items: center; gap: 12px; }
.chart-date, .chart-value { font-size: 13px; font-variant-numeric: tabular-nums; }
.chart-value { text-align: right; color: var(--muted); }
.chart-bar { height: 12px; display: flex; overflow: hidden; border-radius: 999px; background: var(--surface-raised); }
.chart-bar .success { width: var(--success-width); background: var(--success); }
.chart-bar .problem { width: var(--problem-width); background: var(--danger); }
.chart-legend { display: flex; gap: 18px; color: var(--muted); font-size: 13px; }
.chart-legend span::before { content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 2px; background: var(--success); }
.chart-legend span:last-child::before { background: var(--danger); }
.worker-list { display: grid; }
.worker-item { display: grid; gap: 7px; padding: 14px 0; }
.worker-item + .worker-item { border-top: 1px solid var(--border-soft); }
.worker-meta { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 13px; }

.toolbar { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; padding: 18px 22px; border-bottom: 1px solid var(--border-soft); }
.toolbar .grow { flex: 1 1 260px; }
.toolbar label { min-width: 150px; }
.toolbar-actions { display: flex; gap: 10px; flex-wrap: wrap; }
label { display: grid; gap: 6px; color: var(--text); font-weight: 700; }
label > span, .field-label { font-size: 13px; }
input, select, textarea { width: 100%; min-height: 44px; padding: 9px 12px; color: var(--text); background: var(--surface-raised); border: 1px solid var(--border); border-radius: 9px; }
textarea { min-height: 112px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: color-mix(in oklch, var(--border), var(--text) 18%); }
button, .button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px; color: oklch(0.16 0.02 255); background: var(--primary); border: 1px solid transparent; border-radius: 9px; font-weight: 800; text-decoration: none; cursor: pointer; }
button:hover, .button:hover { background: var(--primary-hover); }
button.secondary, .button.secondary { color: var(--text); background: transparent; border-color: var(--border); }
button.secondary:hover, .button.secondary:hover { background: var(--surface-hover); }
button.danger, .button.danger { color: oklch(0.97 0.01 25); background: var(--danger); }
button.danger:hover, .button.danger:hover { background: color-mix(in oklch, var(--danger), var(--text) 10%); }
button.compact, .button.compact { min-height: 36px; padding: 6px 11px; font-size: 13px; }
button:disabled { opacity: .52; cursor: wait; }
.icon-button { min-width: 42px; padding: 7px; color: var(--muted); background: transparent; border-color: transparent; font-size: 12px; }
.icon-button:hover { color: var(--text); background: var(--surface-raised); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid color-mix(in oklch, var(--primary), var(--text) 16%); outline-offset: 2px; }

.notice { display: grid; gap: 7px; padding: 15px 17px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-raised); }
.notice.success { border-color: color-mix(in oklch, var(--success), var(--border) 38%); background: color-mix(in oklch, var(--success), var(--surface) 90%); }
.notice.error { border-color: color-mix(in oklch, var(--danger), var(--border) 28%); background: color-mix(in oklch, var(--danger), var(--surface) 91%); }
.notice.warning { border-color: color-mix(in oklch, var(--warning), var(--border) 40%); background: color-mix(in oklch, var(--warning), var(--surface) 92%); }
.notice-help { color: var(--muted); font-size: 13px; }
.copy-row { display: flex; align-items: center; gap: 10px; }
.copy-row code { min-width: 0; flex: 1; padding: 9px 11px; overflow-wrap: anywhere; background: var(--bg); border-radius: 7px; color: var(--text); }

.table-wrap { min-width: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--border-soft); text-align: left; vertical-align: top; }
th { color: var(--muted); background: color-mix(in oklch, var(--surface), var(--surface-raised) 36%); font-size: 12px; font-weight: 800; letter-spacing: .02em; white-space: nowrap; }
tbody tr:hover { background: color-mix(in oklch, var(--surface), var(--surface-raised) 36%); }
tbody tr:last-child td { border-bottom: 0; }
td.actions { min-width: 132px; }
.cell-primary { display: block; color: var(--text); font-weight: 730; }
.cell-secondary { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; }
.truncate { display: block; max-width: 48ch; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.status { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.status::before { content: ''; width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: var(--info); box-shadow: 0 0 0 3px color-mix(in oklch, var(--info), transparent 83%); }
.status.ok { color: var(--success); }
.status.ok::before { background: var(--success); box-shadow: 0 0 0 3px color-mix(in oklch, var(--success), transparent 83%); }
.status.warn { color: var(--warning); }
.status.warn::before { border-radius: 2px; background: var(--warning); box-shadow: 0 0 0 3px color-mix(in oklch, var(--warning), transparent 84%); }
.status.bad { color: var(--danger); }
.status.bad::before { border-radius: 2px; transform: rotate(45deg); background: var(--danger); box-shadow: 0 0 0 3px color-mix(in oklch, var(--danger), transparent 84%); }
.delta.positive { color: var(--success); }
.delta.negative { color: var(--danger); }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--border-soft); }
.pagination > div { display: flex; gap: 8px; }
.empty { padding: 42px 22px !important; text-align: center; color: var(--muted); }

details.inline-panel { border: 1px solid var(--border-soft); border-radius: var(--radius); background: var(--surface); }
details.inline-panel > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; min-height: 50px; padding: 12px 16px; font-weight: 800; cursor: pointer; }
details.inline-panel > summary::-webkit-details-marker { display: none; }
details.inline-panel > summary::after { content: '展开'; color: var(--muted); font-size: 12px; font-weight: 650; }
details.inline-panel[open] > summary::after { content: '收起'; }
details.inline-panel .detail-content { padding: 4px 16px 18px; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: end; }
.form-grid .full { grid-column: 1 / -1; }
.row-actions summary { width: max-content; list-style: none; color: var(--primary); cursor: pointer; font-weight: 750; }
.row-actions summary::-webkit-details-marker { display: none; }
.row-actions[open] { min-width: 230px; }
.action-stack { display: grid; gap: 9px; margin-top: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-raised); }
.action-stack form { display: grid; gap: 8px; }
.inline-number { max-width: 150px; }
.tabs { display: flex; gap: 4px; padding: 4px; width: max-content; max-width: 100%; overflow-x: auto; background: var(--surface-raised); border-radius: 10px; }
.tabs a { min-height: 38px; display: inline-flex; align-items: center; padding: 7px 12px; border-radius: 7px; color: var(--muted); text-decoration: none; font-weight: 750; white-space: nowrap; }
.tabs a.active { color: var(--text); background: var(--surface); }
.detail-list { display: grid; grid-template-columns: 160px minmax(0, 1fr); }
.detail-list dt, .detail-list dd { margin: 0; padding: 11px 0; border-bottom: 1px solid var(--border-soft); }
.detail-list dt { color: var(--muted); }
.detail-list dd { overflow-wrap: anywhere; }
pre.data-block { max-height: 520px; margin: 0; padding: 16px; overflow: auto; color: var(--text); background: var(--bg); border: 1px solid var(--border-soft); border-radius: 9px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.55; }

.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 28px 18px; background: var(--bg); }
.auth-shell { width: min(520px, 100%); display: grid; gap: 18px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.auth-heading { display: grid; gap: 7px; }
.auth-heading p { color: var(--muted); }
.steps { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.step { padding: 8px 10px; border: 1px solid var(--border-soft); border-radius: 8px; color: var(--faint); font-size: 12px; text-align: center; }
.step.active { border-color: var(--primary); color: var(--text); background: color-mix(in oklch, var(--primary), var(--surface) 92%); }
.security-note { display: flex; gap: 9px; color: var(--muted); font-size: 13px; }
.security-note::before { content: '✓'; color: var(--success); font-weight: 900; }
.qr { display: block; width: min(300px, 100%); margin: 4px auto; padding: 10px; border-radius: 12px; background: oklch(0.98 0.005 255); }
.binding-progress { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.binding-progress span { min-height: 6px; border-radius: 999px; background: var(--surface-raised); }
.binding-progress span.done { background: var(--primary); }

@media (max-width: 1100px) {
    .metric-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .metric:nth-child(3) { border-left: 0; border-top: 1px solid var(--border-soft); }
    .metric:nth-child(4) { border-top: 1px solid var(--border-soft); }
    .section-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
    .app-shell { display: block; }
    .sidebar { position: fixed; inset: 0 auto 0 0; width: min(288px, 86vw); height: 100dvh; transform: translateX(-105%); transition: transform 170ms cubic-bezier(.16, 1, .3, 1); box-shadow: var(--shadow); }
    .menu-open .sidebar { transform: translateX(0); }
    .menu-close { display: inline-flex; }
    .menu-open::after { content: ''; position: fixed; inset: 0; z-index: 10; background: oklch(0.06 0.015 255 / .62); }
    .menu-button { display: inline-flex; min-width: 58px; color: var(--text); background: var(--surface); border-color: var(--border); }
    .topbar { min-height: 98px; padding: 18px 20px; align-items: flex-start; }
    .page-content { padding: 20px 16px 40px; }
    .split-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    h1 { font-size: 23px; }
    .page-subtitle { font-size: 13px; }
    .metric-strip { grid-template-columns: 1fr 1fr; }
    .metric { padding: 15px 16px; }
    .metric strong { font-size: 21px; }
    .panel-header, .panel-body { padding: 17px 16px; }
    .panel-header { display: grid; }
    .toolbar { padding: 16px; align-items: stretch; }
    .toolbar label, .toolbar .grow { flex: 1 1 100%; min-width: 100%; }
    .toolbar-actions { width: 100%; }
    .toolbar-actions > * { flex: 1; }
    .chart-row { grid-template-columns: 60px minmax(90px, 1fr) 66px; gap: 8px; }
    .table-wrap { overflow: visible; }
    table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
    table.responsive thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
    table.responsive tbody { display: grid; gap: 12px; padding: 14px; }
    table.responsive tr { padding: 13px 14px; border: 1px solid var(--border-soft); border-radius: 10px; background: var(--surface-raised); }
    table.responsive td { display: grid; grid-template-columns: minmax(88px, 34%) minmax(0, 1fr); gap: 10px; padding: 7px 0; border: 0; }
    table.responsive td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 800; }
    table.responsive td.actions { min-width: 0; }
    table.responsive td.actions .row-actions[open] { min-width: 0; }
    .truncate { max-width: 100%; }
    .pagination { align-items: flex-start; }
    .copy-row { align-items: stretch; flex-direction: column; }
    .detail-list { grid-template-columns: 1fr; }
    .detail-list dt { padding-bottom: 2px; border-bottom: 0; }
    .detail-list dd { padding-top: 2px; }
    .auth-card { padding: 22px 18px; }
}

@media (prefers-reduced-motion: no-preference) {
    button, a, input, select, textarea { transition: color 150ms, background-color 150ms, border-color 150ms, box-shadow 150ms, opacity 150ms; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
