:root {
  color-scheme: light;
  font-family: "Microsoft YaHei UI", "Segoe UI", Arial, sans-serif;
  background: #f5f7fb;
  color: #111827;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #dfe5ee;
  --line-strong: #c6d1de;
  --ink: #111827;
  --muted: #5f6b7a;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #e8f0ff;
  --good: #047857;
  --good-bg: #e8f7ef;
  --warn: #b45309;
  --warn-bg: #fff7e6;
  --bad: #b42318;
  --bad-bg: #fff0ed;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
  --ease: cubic-bezier(.2,.8,.2,1);
}

* { box-sizing: border-box; }
html { min-width: 320px; max-width: 100%; overflow-x: clip; }
body { margin: 0; background: var(--bg); max-width: 100%; overflow-x: clip; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.65; }
a { color: inherit; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: 28px; line-height: 1.15; letter-spacing: 0; }
h2 { margin-bottom: 12px; font-size: 18px; line-height: 1.25; }
h3 { margin-bottom: 8px; font-size: 15px; }
.muted { margin-bottom: 0; color: var(--muted); line-height: 1.65; }
.mono, .hash, pre, .code-editor { font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace; }
.hash { max-width: 380px; overflow-wrap: anywhere; font-size: 12px; }
.eyebrow { margin: 0 0 6px; color: var(--primary); text-transform: uppercase; letter-spacing: 0.08em; font-size: 12px; font-weight: 800; }

.login-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.12), transparent 40%),
    radial-gradient(circle at 82% 12%, rgba(4, 120, 87, 0.10), transparent 34%),
    #f5f7fb;
}

.login-panel {
  width: min(460px, 100%);
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 28px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.form-stack, .page-stack, .editor-panel { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; color: #374151; font-weight: 700; font-size: 13px; }
input, textarea, select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  outline: none;
}
textarea { resize: vertical; line-height: 1.55; }
input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.captcha-row { display: grid; grid-template-columns: 1fr 150px; gap: 10px; align-items: end; }
.captcha-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  font-weight: 800;
}
.captcha-button img { width: 100%; height: 42px; object-fit: cover; display: block; }

.btn {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: 8px 12px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
  transition: transform 0.18s var(--ease), background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}
.btn:hover { transform: translateY(-1px); border-color: var(--line-strong); background: #f9fafb; box-shadow: 0 8px 20px rgba(15, 23, 42, 0.07); }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn.ghost { background: transparent; }
.btn.compact { min-height: 30px; padding: 5px 8px; font-size: 12px; }
.btn.full { width: 100%; }
.btn.danger { color: var(--bad); border-color: #f0b8b1; }
.btn.danger:hover { background: var(--bad-bg); color: var(--bad); }
.button-row, .top-actions, .toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.alert-line, .notice {
  border: 1px solid #f0c36a;
  background: var(--warn-bg);
  color: #7a3b00;
  border-radius: 6px;
  padding: 11px 12px;
  line-height: 1.55;
}

.toast {
  position: fixed;
  z-index: 1000;
  top: 18px;
  left: 50%;
  min-width: min(420px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 12px 18px;
  color: #102033;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.16);
  backdrop-filter: blur(14px);
  text-align: center;
  font-weight: 900;
  animation: toastIn 0.18s var(--ease);
}
.toast.success { border-color: #b7e4ca; background: rgba(232, 247, 239, 0.96); color: var(--good); }
.toast.warn { border-color: #f4d38c; background: rgba(255, 247, 230, 0.96); color: var(--warn); }
.toast.error { border-color: #f0b8b1; background: rgba(255, 240, 237, 0.96); color: var(--bad); }

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, -8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.app-shell { min-height: 100dvh; max-width: 100vw; overflow-x: hidden; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100dvh;
  min-width: 0;
  max-width: 260px;
  overflow-x: hidden;
}
.brand { display: flex; gap: 12px; align-items: center; min-width: 0; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.brand-mark { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: #111827; color: #fff; }
.brand-mark img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
.brand strong { display: block; }
.brand small { display: block; color: var(--muted); margin-top: 2px; }
.brand > div { min-width: 0; overflow: hidden; }
.brand strong, .brand small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-groups { display: flex; flex-direction: column; gap: 14px; flex: 1; min-width: 0; overflow-y: auto; overflow-x: hidden; scrollbar-gutter: stable; }
.nav-group { display: flex; flex-direction: column; gap: 5px; min-width: 0; overflow-x: hidden; }
.nav-group p {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.nav-group button, .logout {
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #526070;
  font-weight: 800;
  transition: background-color 0.18s ease, color 0.18s ease;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  flex: 0 0 auto;
}
.nav-group button svg, .logout svg { flex: 0 0 auto; }
.nav-group button span, .logout span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-group button:hover, .logout:hover { background: #eef4ff; color: var(--primary-dark); box-shadow: inset 3px 0 0 var(--primary); overflow: hidden; }
.nav-group button.active { background: var(--primary-soft); color: var(--primary-dark); }
.logout { color: #7f1d1d; }

.workspace { min-width: 0; max-width: 100%; overflow-x: hidden; padding: 24px; display: flex; flex-direction: column; gap: 18px; }
.topbar, .section-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.topbar { min-height: 72px; }
.section-head h2 { margin: 0; }
.section-head a { color: var(--primary); font-weight: 800; text-decoration: none; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric, .panel {
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.04);
}
.panel-soft {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
  padding: 14px;
}
.metric, .panel, .revision-list button, .nested-card {
  transition: transform 0.2s var(--ease), border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}
.metric:hover, .panel:hover, .revision-list button:hover, .nested-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}
.metric { min-height: 116px; display: flex; flex-direction: column; justify-content: space-between; }
.metric span, .metric small { color: var(--muted); }
.metric strong { font-size: 26px; overflow-wrap: anywhere; }

.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.chart-panel { min-height: 330px; display: flex; flex-direction: column; }
.chart-panel-relative { position: relative; }
.chart { min-height: 260px; width: 100%; flex: 1; }
.chart-empty {
  position: absolute;
  inset: 56px 16px 16px;
  display: grid;
  place-content: center;
  gap: 6px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: rgba(248, 250, 252, 0.84);
  color: var(--muted);
  text-align: center;
  pointer-events: none;
}
.chart-empty strong { color: var(--ink); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 14px; align-items: start; }
.split.wide-split { grid-template-columns: minmax(380px, 0.95fr) minmax(0, 1.05fr); }
.legacy-media-editor { grid-template-columns: minmax(340px, 0.95fr) minmax(0, 1.05fr); }
.legacy-media-editor > * { min-width: 0; }

.search-box {
  min-width: min(420px, 100%);
  flex: 1;
  display: flex;
  flex-direction: row;
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--muted);
}
.search-box input { border: 0; box-shadow: none; }
.search-box input:focus { box-shadow: none; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { border-bottom: 1px solid var(--line); padding: 10px 8px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
tr.clickable { cursor: pointer; }
tbody tr { transition: background-color 0.18s ease; }
tr.clickable:hover td, tbody tr:hover td { background: #f8fbff; }
tr.selected td { background: #eef4ff; }

.badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f3f4f6;
  color: #374151;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}
.badge.good { background: var(--good-bg); color: var(--good); border-color: #b7e4ca; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: #f4d38c; }
.badge.bad { background: var(--bad-bg); color: var(--bad); border-color: #f0b8b1; }
.badge.neutral { background: #f3f4f6; color: #4b5563; border-color: var(--line); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.checkbox { flex-direction: row; align-items: center; font-weight: 700; color: var(--muted); }
.checkbox input { width: auto; min-height: auto; }
.detail-panel { position: sticky; top: 18px; max-height: calc(100dvh - 36px); overflow: auto; }
hr { border: 0; border-top: 1px solid var(--line); width: 100%; margin: 12px 0; }
.comment-list { display: flex; flex-direction: column; gap: 8px; }
.comment { border: 1px solid var(--line); border-radius: 6px; padding: 9px; background: var(--panel-soft); }
.comment p { margin: 4px 0 0; color: var(--muted); }
.empty-state { min-height: 220px; display: grid; place-items: center; align-content: center; gap: 10px; color: var(--muted); text-align: center; }
.empty-state.compact { min-height: 96px; border: 1px dashed var(--line); border-radius: 6px; }
.source-group { margin-top: 12px; }
.source-group h3 { display: flex; align-items: center; gap: 8px; }
.table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-gutter: stable;
}
.media-subcategory-panel { min-width: 0; overflow: hidden; }
.media-subcategory-table table { table-layout: fixed; min-width: 680px; }
.media-subcategory-table th:nth-child(1), .media-subcategory-table td:nth-child(1) { width: 170px; }
.media-subcategory-table th:nth-child(2), .media-subcategory-table td:nth-child(2) { width: 120px; }
.media-subcategory-table th:nth-child(3), .media-subcategory-table td:nth-child(3) { width: 72px; }
.media-subcategory-table th:nth-child(5), .media-subcategory-table td:nth-child(5) { width: 150px; }
.media-subcategory-table .button-row { flex-wrap: nowrap; }
.url-cell {
  max-width: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.category-list { display: flex; flex-direction: column; gap: 8px; }
.category-list button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}
.category-list button:hover, .category-list button.active {
  border-color: rgba(37, 99, 235, 0.35);
  background: var(--primary-soft);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.08);
}
.category-list span:first-child { min-width: 0; display: grid; gap: 2px; }
.category-list strong, .category-list small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code-editor { min-height: 56dvh; white-space: pre; overflow: auto; font-size: 13px; }
.compact-editor { min-height: 260px; }
details {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: #fff;
}
summary { cursor: pointer; font-weight: 900; margin-bottom: 10px; }
.json-preview {
  margin: 0;
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0f172a;
  color: #dbeafe;
  padding: 12px;
  font-size: 12px;
  line-height: 1.6;
}
.json-preview.small { max-height: 260px; }
.json-preview.tall { max-height: 70dvh; }
.revision-list { display: flex; flex-direction: column; gap: 8px; }
.revision-list button {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  padding: 10px;
}
.revision-list button:hover, .revision-list button.active { border-color: var(--primary); background: #f8fbff; }
.revision-list small { display: block; color: var(--muted); margin-top: 3px; }
.compact-side { gap: 10px; }
.kv-grid { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 11px 14px; }
.kv-grid span { color: var(--muted); }
.kv-grid strong { overflow-wrap: anywhere; }
.sync-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.sync-summary div {
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
  padding: 10px;
}
.sync-summary span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.sync-summary strong {
  display: block;
  margin-top: 8px;
  overflow-wrap: anywhere;
  font-size: 18px;
}
.ops-note {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  border: 1px solid #f4d38c;
  border-radius: 10px;
  background: var(--warn-bg);
  color: #7a3b00;
  padding: 10px 12px;
  line-height: 1.55;
}
.ops-note svg { flex: 0 0 auto; margin-top: 3px; }
.plain-list { margin: 0; padding-left: 18px; color: var(--muted); line-height: 1.8; }
.asset-row {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 10px;
}
.asset-row span { color: var(--muted); }
.asset-row code { overflow-wrap: anywhere; font-size: 12px; color: var(--primary-dark); }
.brand-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
  padding: 10px;
}
.brand-preview img {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--line);
}
.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  color: var(--muted);
  font-weight: 800;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.42);
}
.modal-panel {
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100dvh - 40px);
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 18px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}
.tabs button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 7px 12px;
  font-weight: 900;
  transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.tabs button:hover, .tabs button.active {
  border-color: rgba(37, 99, 235, 0.28);
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.form-grid .wide, label.wide { grid-column: 1 / -1; }
.mini-editor { min-height: 160px; }
.nested-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(248, 250, 252, 0.78);
  padding: 14px;
}
.nested-card.inner {
  margin-top: 12px;
  background: #fff;
}
.upload-card {
  background: #fff;
}
.upload-progress {
  display: grid;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
  padding: 10px 12px;
}
.upload-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}
.upload-progress-head strong { color: var(--ink); }
.upload-progress-head span { color: var(--primary-dark); font-weight: 900; }
.progress-track {
  width: 100%;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e7eb;
}
.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.18s var(--ease);
}
.upload-progress small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-grid, .split, .split.wide-split, .sync-summary { grid-template-columns: 1fr; }
  .detail-panel { position: static; max-height: none; }
}

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .nav-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace { padding: 16px; }
  .topbar, .section-head { align-items: stretch; flex-direction: column; }
  .metric-grid, .two-col { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .captcha-row { grid-template-columns: 1fr; }
  table { min-width: 720px; }
  .panel { overflow-x: auto; max-width: 100%; }
}

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