:root {
  --brand: #e85d0f;
  --brand-dark: #b83f00;
  --brand-soft: #fff2e8;
  --ink: #17212b;
  --ink-muted: #586574;
  --surface: #ffffff;
  --surface-subtle: #f5f7f9;
  --line: #d9e0e6;
  --line-strong: #b9c3cc;
  --success: #137a4b;
  --success-soft: #e8f7ef;
  --warning: #8a5a00;
  --warning-soft: #fff5d7;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --focus: #1264a3;
  --shadow: 0 10px 30px rgba(22, 33, 43, 0.08);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --sidebar-width: 232px;
  font-family: "Segoe UI", "Microsoft YaHei UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--surface-subtle);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--surface-subtle); }
body { margin: 0; min-height: 100vh; line-height: 1.5; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled, input:disabled { cursor: not-allowed; opacity: .55; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--focus) 60%, white); outline-offset: 2px; }
.hidden { display: none !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; }
.skip-link { position: fixed; left: 16px; top: -80px; z-index: 2000; padding: 10px 16px; color: white; background: var(--focus); border-radius: var(--radius-sm); white-space: nowrap; }
.skip-link:focus { top: 16px; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 32px 20px; background: linear-gradient(135deg, #fff 0%, #fff8f3 55%, #f4f7f9 100%); }
.login-card { width: min(100%, 440px); padding: 40px; background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--brand); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.brand-mark { display: grid; place-items: center; width: 56px; height: 56px; margin-bottom: 22px; color: var(--brand); background: var(--brand-soft); border-radius: 14px; }
.brand-mark svg { width: 34px; height: 34px; }
.eyebrow { margin: 0 0 6px; color: var(--brand-dark); font-size: 12px; font-weight: 700; letter-spacing: .1em; }
.login-card h1, .page-heading h1 { margin: 0; font-size: clamp(26px, 4vw, 34px); line-height: 1.2; }
.login-intro { margin: 12px 0 28px; color: var(--ink-muted); }
.login-footnote { margin: 24px 0 0; color: var(--ink-muted); font-size: 13px; text-align: center; }

.field { margin-bottom: 18px; }
.field label { display: block; margin-bottom: 7px; color: var(--ink); font-size: 14px; font-weight: 650; }
.field input, .field select, .field textarea, .metric-grid input, select { width: 100%; min-height: 44px; padding: 10px 12px; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); }
.field textarea { resize: vertical; }
.field input[readonly] { color: var(--ink-muted); background: var(--surface-subtle); }
.field-error { min-height: 21px; margin: 6px 0 0; color: var(--danger); font-size: 13px; }
.helper-text { margin: 7px 0 0; color: var(--ink-muted); font-size: 13px; }

.button { min-height: 44px; padding: 10px 16px; border: 1px solid transparent; border-radius: var(--radius-sm); font-weight: 650; transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease; }
.button:active { box-shadow: inset 0 2px 4px rgba(0,0,0,.12); }
.button-primary { color: white; background: var(--brand); border-color: var(--brand); }
.button-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.button-secondary { color: var(--ink); background: var(--surface); border-color: var(--line-strong); }
.button-secondary:hover { background: #edf1f4; }
.button-ghost { color: var(--ink-muted); background: transparent; border-color: transparent; }
.button-ghost:hover { color: var(--ink); background: #edf1f4; }
.button-danger { color: white; background: var(--danger); border-color: var(--danger); }
.button-full { width: 100%; }
.icon-button { min-width: 44px; min-height: 44px; padding: 6px; color: var(--ink-muted); background: transparent; border: 0; border-radius: var(--radius-sm); font-size: 28px; line-height: 1; }
.icon-button:hover { color: var(--ink); background: var(--surface-subtle); }

.app-shell { min-height: 100vh; padding-top: 72px; padding-left: var(--sidebar-width); }
.topbar { position: fixed; z-index: 100; inset: 0 0 auto 0; height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; background: rgba(255,255,255,.97); border-bottom: 1px solid var(--line); }
.topbar-brand { display: flex; align-items: center; gap: 12px; }
.topbar-brand strong, .topbar-brand span { display: block; }
.topbar-brand span { color: var(--ink-muted); font-size: 12px; }
.brand-dot { width: 10px; height: 32px; background: var(--brand); border-radius: 4px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.sidebar { position: fixed; z-index: 90; left: 0; top: 72px; bottom: 0; width: var(--sidebar-width); display: flex; flex-direction: column; justify-content: space-between; padding: 20px 12px; background: #202a34; color: white; }
.sidebar nav { display: grid; gap: 6px; }
.nav-item { min-height: 48px; display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 14px; color: #dce3e8; background: transparent; border: 1px solid transparent; border-radius: 8px; text-align: left; font-weight: 600; }
.nav-item svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-item:hover { background: #2c3945; }
.nav-item.active { color: white; background: #374551; border-color: #4b5a66; box-shadow: inset 3px 0 var(--brand); }
.sidebar-foot { padding: 16px 14px 4px; border-top: 1px solid #3a4650; }
.sidebar-foot span, .sidebar-foot strong { display: block; }
.sidebar-foot span { color: #aebac4; font-size: 12px; }
.main-content { min-height: calc(100vh - 72px); padding: 32px; }
.view-panel { max-width: 1480px; margin: 0 auto; }

.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.page-heading p:not(.eyebrow) { margin: 8px 0 0; color: var(--ink-muted); }
.heading-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.compact-actions .button { min-height: 38px; padding: 7px 11px; }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.summary-card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 3px 14px rgba(22,33,43,.035); }
.summary-card { min-height: 126px; padding: 20px; border-top: 3px solid #cdd5dc; }
.summary-card:first-child { border-top-color: var(--brand); }
.summary-card span, .summary-card small { display: block; color: var(--ink-muted); }
.summary-card strong { display: block; margin: 8px 0 4px; font-size: 25px; font-variant-numeric: tabular-nums; }
.editor-layout { display: grid; grid-template-columns: minmax(320px, 430px) minmax(0, 1fr); gap: 20px; align-items: start; }
.panel { padding: 22px; }
.panel-heading { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.panel h2 { margin: 0; font-size: 19px; }
.panel-heading p { margin: 4px 0 0; color: var(--ink-muted); font-size: 14px; }
.readonly-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 20px; }
.readonly-grid div { padding: 12px; background: var(--surface-subtle); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.readonly-grid span, .readonly-grid strong { display: block; overflow-wrap: anywhere; }
.readonly-grid span { color: var(--ink-muted); font-size: 12px; }
.readonly-grid strong { margin-top: 4px; font-size: 14px; }
.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.metric-grid .field { margin: 0; }
.notice { margin-top: 20px; padding: 14px 16px; border: 1px solid; border-radius: var(--radius-sm); }
.notice strong, .notice p { display: block; margin: 0; }
.notice p { margin-top: 4px; font-size: 13px; }
.notice-info { color: #174b72; background: #edf7ff; border-color: #b7d9f1; }
.notice-warning { color: var(--warning); background: var(--warning-soft); border-color: #e7cc7f; }
.json-editor { width: 100%; min-height: 610px; padding: 16px; resize: vertical; color: #e9eef2; background: #182129; border: 1px solid #3d4b57; border-radius: var(--radius-sm); font: 13px/1.6 Consolas, "Cascadia Mono", monospace; tab-size: 2; white-space: pre; }
.validation-panel { margin-top: 20px; }
.validation-results { display: grid; gap: 8px; }
.validation-item { padding: 12px 14px; border-left: 4px solid; border-radius: 4px; background: var(--surface-subtle); }
.validation-item strong, .validation-item code { display: block; }
.validation-item code { margin-top: 3px; color: var(--ink-muted); font-size: 12px; overflow-wrap: anywhere; }
.validation-error { border-color: var(--danger); background: var(--danger-soft); }
.validation-warning { border-color: #c58b00; background: var(--warning-soft); }
.validation-success { border-color: var(--success); background: var(--success-soft); }

.status-pill { display: inline-flex; align-items: center; min-height: 30px; padding: 4px 10px; color: var(--ink-muted); background: #edf1f4; border: 1px solid var(--line); border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.status-success { color: var(--success); background: var(--success-soft); border-color: #add7c1; }
.status-warning { color: var(--warning); background: var(--warning-soft); border-color: #dfc16d; }
.status-danger { color: var(--danger); background: var(--danger-soft); border-color: #efb6af; }

.table-panel { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 16px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { color: var(--ink-muted); background: var(--surface-subtle); font-size: 13px; font-weight: 700; white-space: nowrap; }
td { font-size: 14px; }
tbody tr:last-child td { border-bottom: 0; }
.table-action { min-height: 36px; padding: 6px 10px; }
.assets-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.asset-card { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.asset-preview { display: grid; place-items: center; height: 160px; padding: 18px; background: repeating-conic-gradient(#f0f2f4 0 25%, white 0 50%) 50% / 18px 18px; }
.asset-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.asset-meta { padding: 14px; }
.asset-meta strong, .asset-meta span { display: block; overflow-wrap: anywhere; }
.asset-meta span { margin-top: 4px; color: var(--ink-muted); font-size: 12px; }
.integration-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.endpoint-card code { display: block; min-height: 70px; margin: 16px 0; padding: 12px; color: #174b72; background: #edf7ff; border-radius: var(--radius-sm); overflow-wrap: anywhere; }
.rule-list { margin: 16px 0 0; padding-left: 24px; }
.rule-list li { margin: 8px 0; }

.technical-layout { display: grid; grid-template-columns: minmax(320px, 440px) minmax(0, 1fr); gap: 20px; align-items: start; }
.technical-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.technical-filters .field { margin-bottom: 12px; }
.technical-list { min-height: 420px; max-height: 720px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.technical-list-item { display: block; width: 100%; min-height: 72px; padding: 12px 14px; color: var(--ink); background: var(--surface); border: 0; border-bottom: 1px solid var(--line); text-align: left; }
.technical-list-item:last-child { border-bottom: 0; }
.technical-list-item:hover { background: var(--surface-subtle); }
.technical-list-item.active { background: var(--brand-soft); box-shadow: inset 4px 0 var(--brand); }
.technical-list-item strong, .technical-list-item span { display: block; }
.technical-list-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.technical-list-item span { margin-top: 3px; color: var(--ink-muted); font-size: 12px; }
.technical-list-empty, .empty-state { padding: 38px 20px; color: var(--ink-muted); background: var(--surface-subtle); border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); text-align: center; }
.technical-meta-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.technical-content { min-height: 340px; font-family: "Segoe UI", "Microsoft YaHei UI", sans-serif; line-height: 1.7; }
.editor-footer { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 6px; }
.editor-footer .helper-text { max-width: 520px; margin: 0; text-align: right; }
.technical-versions-panel { margin-top: 20px; }
.table-heading { margin: 0; padding: 20px 22px; }
.modal.modal-wide { width: min(94vw, 1120px); }
.technical-json-editor { min-height: 62vh; max-height: 70vh; }
.category-manager-layout { display: grid; grid-template-columns: minmax(270px, .85fr) minmax(320px, 1.15fr); gap: 24px; margin-top: 20px; }
.category-manager-layout > section { min-width: 0; }
.category-manager-layout label { display: block; margin-bottom: 7px; font-size: 14px; font-weight: 650; }
.category-manager-layout h3 { margin: 0 0 18px; }
.category-manager-list { min-height: 390px; margin-bottom: 12px; }

.modal { width: min(92vw, 560px); padding: 0; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: 0 24px 80px rgba(0,0,0,.22); }
.modal::backdrop { background: rgba(17, 26, 34, .55); }
.modal form { padding: 24px; }
.modal-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.modal-heading h2 { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.toast-region { position: fixed; z-index: 3000; right: 20px; bottom: 20px; display: grid; gap: 10px; width: min(380px, calc(100vw - 40px)); }
.toast { padding: 14px 16px; color: white; background: #26333e; border-left: 5px solid var(--brand); border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.toast.error { border-left-color: #ff756b; }

@media (max-width: 1100px) {
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .editor-layout { grid-template-columns: 1fr; }
  .json-editor { min-height: 500px; }
  .integration-grid { grid-template-columns: 1fr; }
  .technical-layout { grid-template-columns: 1fr; }
  .technical-list { max-height: 480px; }
}

@media (max-width: 820px) {
  :root { --sidebar-width: 0px; }
  .app-shell { padding-left: 0; padding-top: 128px; }
  .topbar { height: 72px; padding: 0 16px; }
  .topbar-actions .status-pill { display: none; }
  .sidebar { top: 72px; bottom: auto; width: 100%; height: 56px; display: block; padding: 4px 8px; overflow-x: auto; background: #202a34; }
  .sidebar nav { display: flex; width: max-content; gap: 4px; }
  .nav-item { width: auto; min-height: 48px; padding: 8px 12px; white-space: nowrap; }
  .nav-item svg { width: 20px; height: 20px; }
  .sidebar-foot { display: none; }
  .main-content { min-height: calc(100vh - 128px); padding: 24px 18px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .heading-actions { width: 100%; justify-content: flex-start; }
}

@media (max-width: 560px) {
  .login-card { padding: 28px 22px; }
  .topbar-brand span, .topbar-actions .button-ghost:first-of-type { display: none; }
  .topbar-actions .button { padding-inline: 10px; }
  .summary-grid, .metric-grid, .readonly-grid { grid-template-columns: 1fr; }
  .summary-card { min-height: 105px; }
  .heading-actions .button { flex: 1 1 calc(50% - 8px); }
  .panel { padding: 18px; }
  .json-editor { min-height: 420px; font-size: 12px; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .button { width: 100%; }
  .technical-filters, .technical-meta-grid { grid-template-columns: 1fr; }
  .category-manager-layout { grid-template-columns: 1fr; }
  .category-manager-list { min-height: 220px; }
  .editor-footer { align-items: stretch; flex-direction: column; }
  .editor-footer .helper-text { text-align: left; }
}

@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; }
}
