:root {
  --color-brand-50: #eef2ff;
  --color-brand-100: #e0e7ff;
  --color-brand-200: #c7d2fe;
  --color-brand-500: #6366f1;
  --color-brand-600: #4f46e5;
  --color-brand-700: #4338ca;
  --color-brand-800: #3730a3;
  --color-ai: #7c3aed;
  --color-bg-page: #f7f8fc;
  --color-bg-surface: #ffffff;
  --color-bg-subtle: #f2f4f8;
  --color-bg-scrim: rgba(17, 24, 39, 0.48);
  --color-text-primary: #111827;
  --color-text-secondary: #4b5563;
  --color-text-tertiary: #6b7280;
  --color-text-inverse: #ffffff;
  --color-border-default: #e5e7eb;
  --color-border-strong: #d1d5db;
  --color-success-text: #166534;
  --color-success-bg: #f0fdf4;
  --color-warning-text: #92400e;
  --color-warning-bg: #fffbeb;
  --color-error-text: #991b1b;
  --color-error-bg: #fef2f2;
  --color-info-text: #075985;
  --color-info-bg: #f0f9ff;
  --color-neutral-bg: #f3f4f6;
  --color-focus-ring: #4f46e5;
  --gradient-brand-cta: linear-gradient(135deg, #4f46e5 0%, #4338ca 58%, #7c3aed 100%);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 999px;
  --shadow-low: 0 2px 10px rgba(17, 24, 39, 0.06);
  --shadow-mid: 0 8px 24px rgba(17, 24, 39, 0.12);
  --motion-fast: 120ms;
  --motion-normal: 180ms;
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--color-bg-page); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--color-text-primary);
  background: var(--color-bg-page);
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }

:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: -80px;
  z-index: 1000;
  padding: 10px 16px;
  color: var(--color-text-inverse);
  background: var(--color-brand-700);
  border-radius: var(--radius-md);
}
.skip-link:focus { top: 16px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 264px minmax(0, 1fr); }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 20px 16px 24px;
  background: var(--color-bg-surface);
  border-right: 1px solid var(--color-border-default);
}

.brand { padding: 4px 8px 22px; border-bottom: 1px solid var(--color-border-default); }
.brand__eyebrow { margin: 0 0 2px; color: var(--color-brand-700); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; }
.brand__name { margin: 0; font-size: 20px; line-height: 28px; font-weight: 700; }
.brand__meta { margin: 4px 0 0; color: var(--color-text-tertiary); font-size: 12px; }

.nav { padding-top: 16px; }
.nav__section + .nav__section { margin-top: 16px; }
.nav__label { margin: 0 10px 6px; color: var(--color-text-tertiary); font-size: 12px; font-weight: 600; }
.nav__link {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  color: var(--color-text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: background var(--motion-fast) var(--ease-standard), color var(--motion-fast) var(--ease-standard);
}
.nav__link:hover { background: var(--color-bg-subtle); color: var(--color-text-primary); }
.nav__link[aria-current="page"] { color: var(--color-brand-800); background: var(--color-brand-50); font-weight: 600; }
.nav__priority { color: var(--color-ai); font-size: 12px; font-weight: 700; }

.app-main { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 28px;
  background: rgba(247, 248, 252, 0.94);
  border-bottom: 1px solid var(--color-border-default);
  backdrop-filter: blur(12px);
}
.topbar__context { min-width: 0; }
.topbar__title { margin: 0; font-size: 20px; line-height: 28px; font-weight: 700; }
.topbar__id { margin: 1px 0 0; color: var(--color-text-tertiary); font-size: 12px; }
.topbar__account { display: flex; align-items: center; gap: 10px; }
.account-copy { text-align: right; }
.account-copy strong, .account-copy span { display: block; }
.account-copy span { color: var(--color-text-tertiary); font-size: 12px; }

.page { width: min(1480px, 100%); margin: 0 auto; padding: 28px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-header__copy { max-width: 780px; }
.page-header h1 { margin: 0; font-size: 24px; line-height: 32px; font-weight: 700; }
.page-header p { margin: 6px 0 0; color: var(--color-text-secondary); }
.page-header__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.section { margin-top: 24px; }
.section:first-child { margin-top: 0; }
.section__header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.section__title { margin: 0; font-size: 17px; line-height: 24px; font-weight: 600; }
.section__hint { margin: 2px 0 0; color: var(--color-text-tertiary); font-size: 14px; }

.surface { background: var(--color-bg-surface); border: 1px solid var(--color-border-default); border-radius: var(--radius-lg); }
.surface--padded { padding: 20px; }
.surface--shadow { box-shadow: var(--shadow-low); }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric { min-height: 118px; padding: 18px; background: var(--color-bg-surface); border: 1px solid var(--color-border-default); border-radius: var(--radius-lg); }
.metric__label { margin: 0; color: var(--color-text-secondary); font-size: 14px; }
.metric__value { margin: 12px 0 0; font-size: 24px; line-height: 32px; font-weight: 700; font-variant-numeric: tabular-nums; }
.metric__detail { margin: 4px 0 0; color: var(--color-text-tertiary); font-size: 12px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--color-border-default); }
.toolbar .field { min-width: 160px; flex: 0 1 220px; }
.toolbar__spacer { flex: 1 1 auto; }

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  transition: opacity var(--motion-fast) var(--ease-standard), background var(--motion-fast) var(--ease-standard), border-color var(--motion-fast) var(--ease-standard);
}
.button:active { opacity: 0.88; }
.button:disabled { cursor: not-allowed; opacity: 0.48; }
.button--primary { color: var(--color-text-inverse); background: var(--gradient-brand-cta); }
.button--secondary { color: var(--color-brand-700); background: var(--color-bg-surface); border-color: var(--color-brand-200); }
.button--quiet { color: var(--color-text-secondary); background: transparent; border-color: var(--color-border-default); }
.button--danger { color: var(--color-error-text); background: var(--color-error-bg); border-color: #fecaca; }
.button--small { min-height: 36px; padding: 6px 11px; font-size: 14px; }
.button--text { min-height: 36px; padding-inline: 8px; color: var(--color-brand-700); background: transparent; }

.field { display: grid; gap: 6px; }
.field__label { color: var(--color-text-primary); font-size: 14px; font-weight: 600; }
.field__required { margin-left: 4px; color: var(--color-error-text); }
.field__hint { color: var(--color-text-tertiary); font-size: 12px; }
.field__error { color: var(--color-error-text); font-size: 12px; }
.input, .select, .textarea {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  color: var(--color-text-primary);
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
}
.textarea { min-height: 96px; resize: vertical; }
.input:disabled, .select:disabled, .textarea:disabled { color: var(--color-text-tertiary); background: var(--color-bg-subtle); }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--color-error-text); }
.checkbox { min-height: 44px; display: inline-flex; align-items: center; gap: 8px; color: var(--color-text-secondary); }
.checkbox input { width: 18px; height: 18px; accent-color: var(--color-brand-600); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .field--wide { grid-column: 1 / -1; }
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }

.tabs { display: flex; gap: 4px; padding: 4px; overflow-x: auto; background: var(--color-bg-subtle); border-radius: var(--radius-md); }
.tab { min-height: 40px; padding: 7px 14px; color: var(--color-text-secondary); background: transparent; border: 0; border-radius: var(--radius-sm); cursor: pointer; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--color-brand-800); background: var(--color-bg-surface); box-shadow: var(--shadow-low); font-weight: 600; }

.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 13px 16px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--color-border-default); }
.table th { color: var(--color-text-secondary); background: var(--color-bg-subtle); font-size: 12px; font-weight: 700; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbff; }
.table__id { max-width: 210px; color: var(--color-text-secondary); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; overflow-wrap: anywhere; }
.table__actions { display: flex; flex-wrap: wrap; gap: 4px; }

.badge { display: inline-flex; min-height: 26px; align-items: center; padding: 3px 9px; border-radius: var(--radius-full); font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge--success { color: var(--color-success-text); background: var(--color-success-bg); }
.badge--warning { color: var(--color-warning-text); background: var(--color-warning-bg); }
.badge--error { color: var(--color-error-text); background: var(--color-error-bg); }
.badge--info { color: var(--color-info-text); background: var(--color-info-bg); }
.badge--neutral { color: var(--color-text-secondary); background: var(--color-neutral-bg); }
.badge--ai { color: #5b21b6; background: #f5f3ff; }

.callout { padding: 14px 16px; border: 1px solid transparent; border-radius: var(--radius-md); }
.callout + .callout { margin-top: 8px; }
.callout__title { margin: 0; font-weight: 700; }
.callout__body { margin: 3px 0 0; color: inherit; }
.callout__meta { margin: 6px 0 0; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; overflow-wrap: anywhere; }
.callout--info { color: var(--color-info-text); background: var(--color-info-bg); border-color: #bae6fd; }
.callout--success { color: var(--color-success-text); background: var(--color-success-bg); border-color: #bbf7d0; }
.callout--warning { color: var(--color-warning-text); background: var(--color-warning-bg); border-color: #fde68a; }
.callout--error { color: var(--color-error-text); background: var(--color-error-bg); border-color: #fecaca; }
.callout__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.empty, .state-panel { min-height: 220px; display: grid; place-items: center; padding: 36px 20px; text-align: center; }
.empty__inner, .state-panel__inner { max-width: 520px; }
.empty h2, .state-panel h2 { margin: 0; font-size: 17px; }
.empty p, .state-panel p { margin: 6px 0 0; color: var(--color-text-secondary); }
.state-panel__actions { display: flex; justify-content: center; gap: 8px; margin-top: 16px; }
.skeleton { display: grid; gap: 10px; padding: 20px; }
.skeleton__line { height: 14px; border-radius: var(--radius-full); background: linear-gradient(90deg, var(--color-bg-subtle), var(--color-brand-50), var(--color-bg-subtle)); background-size: 200% 100%; animation: skeleton 1.4s ease-in-out infinite; }
.skeleton__line:nth-child(2) { width: 76%; }
.skeleton__line:nth-child(3) { width: 58%; }
@keyframes skeleton { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-top: 1px solid var(--color-border-default); }
.pagination__text { color: var(--color-text-tertiary); font-size: 12px; }

.split-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 420px); gap: 16px; align-items: start; }
.detail-list { margin: 0; }
.detail-row { display: grid; grid-template-columns: minmax(120px, 34%) minmax(0, 1fr); gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--color-border-default); }
.detail-row:last-child { border-bottom: 0; }
.detail-row dt { color: var(--color-text-secondary); }
.detail-row dd { margin: 0; overflow-wrap: anywhere; }

.modal-layer { position: fixed; inset: 0; z-index: 500; display: grid; place-items: center; padding: 24px; background: var(--color-bg-scrim); }
.modal { width: min(560px, 100%); max-height: min(760px, calc(100vh - 48px)); overflow-y: auto; background: var(--color-bg-surface); border-radius: var(--radius-xl); box-shadow: var(--shadow-mid); }
.modal__header { padding: 20px 22px 14px; border-bottom: 1px solid var(--color-border-default); }
.modal__header h2 { margin: 0; font-size: 20px; line-height: 28px; }
.modal__header p { margin: 5px 0 0; color: var(--color-text-secondary); }
.modal__body { padding: 20px 22px; }
.modal__footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px 20px; }

.drawer-layer { position: fixed; inset: 0; z-index: 400; background: var(--color-bg-scrim); }
.drawer { position: absolute; inset: 0 0 0 auto; width: min(620px, 100%); overflow-y: auto; background: var(--color-bg-surface); box-shadow: var(--shadow-mid); }
.drawer__header { position: sticky; top: 0; z-index: 1; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px; background: var(--color-bg-surface); border-bottom: 1px solid var(--color-border-default); }
.drawer__header h2 { margin: 0; font-size: 20px; }
.drawer__body { padding: 22px; }

.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 600; width: min(360px, calc(100vw - 40px)); display: grid; gap: 8px; }
.toast { padding: 12px 14px; color: var(--color-text-primary); background: var(--color-bg-surface); border: 1px solid var(--color-border-default); border-radius: var(--radius-md); box-shadow: var(--shadow-mid); }

.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 44%) minmax(0, 1fr); }
.login-panel { display: grid; align-content: center; padding: 48px clamp(32px, 7vw, 96px); background: var(--color-bg-surface); }
.login-panel__inner { width: min(440px, 100%); }
.login-panel h1 { margin: 12px 0 4px; font-size: 32px; line-height: 40px; }
.login-panel p { margin: 0; color: var(--color-text-secondary); }
.login-form { display: grid; grid-template-columns: 1fr; gap: 16px; margin-top: 32px; }
.login-aside { display: grid; align-content: center; padding: 64px; background: var(--color-brand-50); }
.login-aside__inner { max-width: 620px; }
.login-aside h2 { margin: 0; color: var(--color-brand-800); font-size: 24px; line-height: 32px; }
.login-aside p { color: var(--color-text-secondary); }
.login-points { margin: 24px 0 0; padding: 0; list-style: none; }
.login-points li { padding: 12px 0; border-top: 1px solid var(--color-brand-200); }

.code-once { padding: 18px; background: var(--color-warning-bg); border: 1px solid #fde68a; border-radius: var(--radius-md); }
.code-once code { display: block; margin-top: 8px; color: var(--color-text-primary); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 16px; overflow-wrap: anywhere; }

.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
.hidden { display: none !important; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; }
.muted { color: var(--color-text-tertiary); }
.stack { display: grid; gap: 12px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

@media (max-width: 1180px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split-layout { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--color-border-default); }
  .nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .nav__section + .nav__section { margin-top: 0; }
  .topbar { position: static; padding-inline: 20px; }
  .page { padding: 20px; }
  .login-shell { grid-template-columns: 1fr; }
  .login-aside { display: none; }
}

@media (max-width: 640px) {
  .nav { grid-template-columns: 1fr; }
  .page-header { display: grid; }
  .page-header__actions { justify-content: flex-start; }
  .metrics, .form-grid { grid-template-columns: 1fr; }
  .topbar__account .account-copy { display: none; }
  .modal-layer { padding: 12px; }
  .page { padding: 16px; }
}

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