:root {
  --primary: oklch(0.48 0.18 3.4);
  --primary-hover: oklch(0.41 0.16 3.4);
  --primary-soft: oklch(0.95 0.025 3.4);
  --bg: oklch(1 0 0);
  --workspace: oklch(0.965 0.004 250);
  --surface: oklch(0.985 0.002 250);
  --ink: oklch(0.22 0.018 255);
  --muted: oklch(0.48 0.016 255);
  --line: oklch(0.88 0.008 250);
  --line-strong: oklch(0.76 0.012 250);
  --success: oklch(0.46 0.12 155);
  --success-soft: oklch(0.95 0.03 155);
  --warning: oklch(0.56 0.14 75);
  --warning-soft: oklch(0.95 0.04 75);
  --danger-soft: oklch(0.95 0.025 20);
  --danger-ink: oklch(0.4 0.14 20);
  --danger-text: oklch(0.38 0.15 20);
  --success-ink: oklch(0.35 0.1 155);
  --warning-ink: oklch(0.4 0.12 75);
  --notice-ink: oklch(0.38 0.1 75);
  --on-dark-muted: oklch(0.78 0.012 255);
  --on-dark-subtle: oklch(0.72 0.012 255);
  --success-bright: oklch(0.78 0.14 155);
  --danger-bright: oklch(0.76 0.14 20);
  --shadow-low: oklch(0 0 0 / .18);
  --shadow-high: oklch(0 0 0 / .22);
  --sidebar-width: 248px;
  --topbar-height: 76px;
  --z-dropdown: 20;
  --z-sticky: 30;
  --z-backdrop: 40;
  --z-modal: 50;
  --z-toast: 60;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--workspace);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--workspace); }
body { margin: 0; min-height: 100vh; background: var(--workspace); color: var(--ink); font-size: 14px; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
svg { width: 18px; height: 18px; stroke-width: 1.8; flex: none; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid color-mix(in oklch, var(--primary) 28%, transparent); outline-offset: 2px; }

.login-screen { min-height: 100vh; background: var(--bg); }
.login-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 42%) minmax(420px, 1fr); }
.login-identity { background: var(--ink); color: var(--bg); padding: clamp(40px, 7vw, 96px); display: flex; flex-direction: column; align-items: flex-start; justify-content: center; }
.brand-mark { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 8px; background: var(--primary); color: white; font-weight: 800; font-size: 24px; }
.product-name { margin: 28px 0 8px; color: var(--on-dark-muted); font-weight: 600; }
.login-identity h1 { margin: 0; max-width: 8ch; font-size: 38px; line-height: 1.25; letter-spacing: 0; text-wrap: balance; }
.login-facts { width: min(360px, 100%); margin: 72px 0 0; }
.login-facts div { display: flex; justify-content: space-between; gap: 24px; padding: 14px 0; border-bottom: 1px solid oklch(1 0 0 / .14); }
.login-facts dt { color: var(--on-dark-subtle); }
.login-facts dd { margin: 0; font-weight: 600; }
.login-panel { width: min(420px, calc(100% - 48px)); margin: auto; }
.login-heading { margin-bottom: 32px; }
.login-heading h2 { margin: 0 0 8px; font-size: 26px; line-height: 1.3; }
.login-heading p { margin: 0; color: var(--muted); }

.field { display: grid; gap: 7px; margin-bottom: 18px; color: var(--ink); font-size: 13px; font-weight: 650; }
.field small { color: var(--muted); font-weight: 400; }
.input-wrap { position: relative; display: block; }
.input-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-wrap input { padding-left: 40px; }
input, select, textarea { width: 100%; min-height: 42px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--bg); color: var(--ink); padding: 9px 12px; transition: border-color .18s ease, box-shadow .18s ease; }
textarea { min-height: 96px; resize: vertical; line-height: 1.55; }
input::placeholder, textarea::placeholder { color: oklch(0.48 0.012 255); opacity: 1; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: 0; box-shadow: 0 0 0 3px color-mix(in oklch, var(--primary) 16%, transparent); }
input:disabled, select:disabled, textarea:disabled { background: var(--workspace); color: var(--muted); cursor: not-allowed; }
.form-error { margin: -4px 0 16px; padding: 10px 12px; border-radius: 8px; background: var(--danger-soft); color: var(--danger-text); line-height: 1.5; }

.btn { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 8px; padding: 9px 14px; background: var(--bg); color: var(--ink); font-weight: 650; cursor: pointer; transition: background-color .18s ease, border-color .18s ease, color .18s ease, transform .12s ease; white-space: nowrap; }
.btn:hover { background: var(--surface); border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .56; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-secondary { border-color: var(--line-strong); }
.btn-danger { background: var(--danger-soft); color: var(--danger-ink); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--muted); }
.btn-block { width: 100%; }
.icon-btn { width: 40px; height: 40px; display: inline-grid; place-items: center; border: 0; border-radius: 8px; background: transparent; cursor: pointer; color: var(--muted); }
.icon-btn:hover { background: var(--surface); color: var(--ink); }
.icon-btn-sm { width: 34px; height: 34px; }
.icon-btn-sm svg { width: 16px; height: 16px; }
.button-spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: var(--z-sticky); width: var(--sidebar-width); display: flex; flex-direction: column; background: var(--bg); border-right: 1px solid var(--line); }
.sidebar-brand { height: var(--topbar-height); display: flex; align-items: center; gap: 12px; padding: 0 20px; border-bottom: 1px solid var(--line); }
.brand-mark-small { width: 36px; height: 36px; font-size: 17px; }
.sidebar-brand strong, .sidebar-brand span { display: block; }
.sidebar-brand strong { font-size: 15px; }
.sidebar-brand span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.sidebar-close { display: none; margin-left: auto; }
.nav-list { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-list a { min-height: 42px; display: flex; align-items: center; gap: 11px; padding: 0 12px; border-radius: 8px; color: var(--muted); font-weight: 600; }
.nav-list a:hover { background: var(--surface); color: var(--ink); }
.nav-list a.active { background: var(--primary-soft); color: var(--primary-hover); }
.sidebar-account { padding: 12px; border-top: 1px solid var(--line); }
.account-link { min-height: 52px; display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; }
.account-link:hover { background: var(--surface); }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: white; font-size: 13px; font-weight: 700; }
.account-copy { min-width: 0; flex: 1; }
.account-copy strong, .account-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-copy strong { font-size: 13px; }
.account-copy small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.account-link > svg { width: 15px; color: var(--muted); }

.workspace { min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar { height: var(--topbar-height); position: sticky; top: 0; z-index: var(--z-sticky); display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 0 28px; background: color-mix(in oklch, var(--workspace) 94%, transparent); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); }
.topbar-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.page-context { margin: 0 0 2px; color: var(--muted); font-size: 11px; }
.topbar h1 { margin: 0; font-size: 20px; line-height: 1.3; letter-spacing: 0; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.mobile-only { display: none; }
.page-content { width: min(1440px, 100%); margin: 0 auto; padding: 28px; outline: none; }
.page-stack { display: flex; flex-direction: column; gap: 24px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.section-heading h2 { margin: 0; font-size: 17px; line-height: 1.4; }
.section-heading p { margin: 5px 0 0; color: var(--muted); line-height: 1.5; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.metric { min-width: 0; padding: 20px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.metric-label svg { width: 16px; }
.metric-value { margin: 12px 0 0; font-size: 28px; font-weight: 720; font-variant-numeric: tabular-nums; }

.panel { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.panel-header { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel-header h2, .panel-header h3 { margin: 0; font-size: 15px; }
.panel-body { padding: 20px; }
.split-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr); gap: 24px; align-items: start; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.field-full { grid-column: 1 / -1; }
.checkbox-group { display: flex; flex-wrap: wrap; gap: 8px; }
.check-option { min-height: 38px; display: inline-flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 8px; cursor: pointer; font-weight: 500; }
.check-option:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-hover); }
.check-option input { width: 16px; min-height: 16px; margin: 0; accent-color: var(--primary); box-shadow: none; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 4px; }
.result-panel { position: sticky; top: calc(var(--topbar-height) + 28px); }
.result-empty { min-height: 280px; display: grid; place-items: center; padding: 32px; color: var(--muted); text-align: center; }
.result-empty svg { width: 32px; height: 32px; margin-bottom: 12px; }
.result-content { padding: 20px; }
.result-code { min-height: 146px; width: 100%; padding: 12px; background: var(--workspace); border: 0; font-family: Consolas, "SFMono-Regular", monospace; font-size: 12px; word-break: break-all; }
.result-meta { margin: 16px 0; display: grid; gap: 10px; }
.result-meta div { display: flex; justify-content: space-between; gap: 16px; }
.result-meta dt { color: var(--muted); }
.result-meta dd { margin: 0; text-align: right; font-weight: 600; word-break: break-word; }

.toolbar { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; padding: 16px 18px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.toolbar .field { width: 180px; margin: 0; }
.toolbar .field-search { flex: 1; min-width: 240px; }
.toolbar-actions { display: flex; gap: 8px; margin-left: auto; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { padding: 11px 14px; background: var(--surface); color: var(--muted); text-align: left; font-weight: 650; white-space: nowrap; }
.data-table td { padding: 13px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
.data-table tbody tr:hover { background: color-mix(in oklch, var(--surface) 65%, transparent); }
.cell-primary { font-weight: 650; }
.cell-secondary { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.cell-code { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: Consolas, monospace; color: var(--muted); }
.cell-actions { display: flex; justify-content: flex-end; gap: 4px; }
.badge { display: inline-flex; align-items: center; gap: 5px; min-height: 24px; padding: 2px 8px; border-radius: 999px; background: var(--workspace); color: var(--muted); font-size: 11px; font-weight: 650; white-space: nowrap; }
.badge-success { background: var(--success-soft); color: var(--success-ink); }
.badge-warning { background: var(--warning-soft); color: var(--warning-ink); }
.badge-danger { background: var(--danger-soft); color: var(--danger-ink); }
.badge-primary { background: var(--primary-soft); color: var(--primary-hover); }
.pagination { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 14px; border-top: 1px solid var(--line); color: var(--muted); }
.pagination-controls { display: flex; gap: 6px; }
.empty-state { min-height: 260px; display: grid; place-items: center; padding: 40px; text-align: center; color: var(--muted); }
.empty-state svg { width: 34px; height: 34px; margin-bottom: 12px; }
.empty-state strong { display: block; margin-bottom: 5px; color: var(--ink); }

.user-layout { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 24px; align-items: start; }
.user-row-name { display: flex; align-items: center; gap: 10px; }
.user-row-name .avatar { width: 30px; height: 30px; }
.compact-select { width: auto; min-width: 90px; min-height: 34px; padding: 5px 28px 5px 8px; }
.inline-status { display: flex; align-items: center; gap: 8px; }
.audit-summary { max-width: 420px; white-space: normal; line-height: 1.45; }
.profile-layout { max-width: 720px; }
.notice { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 8px; background: var(--warning-soft); color: var(--notice-ink); line-height: 1.5; }

.skeleton { position: relative; overflow: hidden; background: var(--line); border-radius: 4px; color: transparent; }
.skeleton::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, oklch(1 0 0 / .7), transparent); transform: translateX(-100%); animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.skeleton-line { height: 14px; width: 75%; }

.toast-region { position: fixed; z-index: var(--z-toast); right: 20px; bottom: 20px; display: grid; gap: 10px; pointer-events: none; }
.toast { width: min(380px, calc(100vw - 32px)); display: flex; align-items: flex-start; gap: 10px; padding: 13px 14px; border-radius: 8px; background: var(--ink); color: white; box-shadow: 0 4px 8px var(--shadow-low); pointer-events: auto; animation: toast-in .2s cubic-bezier(.22,1,.36,1); }
.toast-success svg { color: var(--success-bright); }
.toast-error svg { color: var(--danger-bright); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.dialog { width: min(520px, calc(100vw - 32px)); max-height: min(720px, calc(100vh - 32px)); padding: 0; border: 0; border-radius: 8px; background: var(--bg); color: var(--ink); box-shadow: 0 8px 24px var(--shadow-high); }
.dialog::backdrop { background: oklch(0.15 0.01 255 / .54); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 0; font-size: 16px; }
.dialog-body { padding: 18px; max-height: 70vh; overflow-y: auto; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); }
.detail-list { margin: 0; display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 12px 16px; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; word-break: break-word; }
.code-block { margin-top: 16px; padding: 12px; max-height: 180px; overflow: auto; border-radius: 4px; background: var(--workspace); font-family: Consolas, monospace; font-size: 12px; line-height: 1.55; word-break: break-all; }
.sidebar-backdrop { position: fixed; inset: 0; z-index: var(--z-backdrop); background: oklch(0.15 0.01 255 / .46); }

@media (max-width: 1100px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .split-layout { grid-template-columns: 1fr; }
  .result-panel { position: static; }
  .user-layout { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .login-layout { grid-template-columns: 1fr; }
  .login-identity { min-height: 210px; padding: 28px 24px; justify-content: flex-start; }
  .login-identity h1 { font-size: 27px; max-width: none; }
  .product-name { margin-top: 18px; }
  .login-facts { display: none; }
  .login-panel { width: calc(100% - 40px); padding: 36px 0 48px; }
  .sidebar { transform: translateX(-100%); transition: transform .22s cubic-bezier(.22,1,.36,1); z-index: calc(var(--z-backdrop) + 1); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close, .mobile-only { display: inline-grid; }
  .workspace { margin-left: 0; }
  .topbar { padding: 0 16px; }
  .top-generate span { display: none; }
  .top-generate { width: 40px; padding: 0; }
  .page-content { padding: 18px 14px 28px; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .field-full { grid-column: auto; }
  .toolbar { align-items: stretch; }
  .toolbar .field, .toolbar .field-search { width: 100%; min-width: 0; }
  .toolbar-actions { width: 100%; margin-left: 0; }
  .toolbar-actions .btn { flex: 1; }
  .data-table thead { display: none; }
  .data-table, .data-table tbody { display: block; }
  .data-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; padding: 14px; border-top: 1px solid var(--line); }
  .data-table tr:first-child { border-top: 0; }
  .data-table td { display: block; padding: 3px 0; border: 0; }
  .data-table td[data-label]::before { content: attr(data-label); display: inline-block; min-width: 76px; margin-right: 8px; color: var(--muted); font-size: 11px; }
  .data-table .mobile-primary { grid-column: 1; }
  .data-table .mobile-actions { grid-column: 2; grid-row: 1; }
  .data-table .mobile-wide { grid-column: 1 / -1; }
  .cell-code { max-width: calc(100vw - 120px); }
  .pagination { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 480px) {
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric { padding: 16px; }
  .metric-value { font-size: 24px; }
  .metric-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .panel-body { padding: 16px; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }
  .detail-list { grid-template-columns: 1fr; gap: 4px; }
  .detail-list dd { margin-bottom: 8px; }
}

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