:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --ink: #1d232c;
  --muted: #687385;
  --line: #dfe4ea;
  --accent: #b40016;
  --accent-dark: #870010;
  --ok: #127c55;
  --warning: #9a6400;
  --focus: #2d6cdf;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(180, 0, 22, 0.04), transparent 34%),
    var(--bg);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 34px;
}

.login-panel h1 {
  margin: 0 0 8px;
  font-size: 26px;
}

.login-panel p {
  margin: 0 0 28px;
  color: var(--muted);
  line-height: 1.7;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #151a22;
  color: #fff;
}

.brand {
  padding: 26px 24px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand strong {
  display: block;
  margin-bottom: 6px;
  font-size: 19px;
}

.brand span {
  color: rgba(255, 255, 255, 0.62);
  font-size: 12px;
}

.nav {
  padding: 14px 12px;
  display: grid;
  gap: 4px;
}

.nav button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  color: rgba(255, 255, 255, 0.75);
  background: transparent;
  border: 0;
  text-align: left;
}

.nav button:hover,
.nav button.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.09);
}

.nav .mark {
  width: 8px;
  height: 8px;
  background: currentColor;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 12px 18px;
  display: grid;
  gap: 8px;
}

.sidebar-footer a,
.sidebar-footer button {
  width: 100%;
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: transparent;
  color: rgba(255, 255, 255, 0.82);
}

.main {
  min-width: 0;
  padding: 28px 32px 56px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.topbar h1 {
  margin: 0 0 6px;
  font-size: 25px;
}

.topbar p {
  margin: 0;
  color: var(--muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.button.primary:hover {
  background: var(--accent-dark);
}

.button.danger {
  border-color: #d8b7bc;
  color: #9a0014;
}

.button.ghost {
  background: transparent;
}

.button.small {
  min-height: 30px;
  padding: 0 10px;
  font-size: 13px;
}

.status {
  min-height: 22px;
  color: var(--muted);
  font-size: 13px;
}

.status.ok {
  color: var(--ok);
}

.status.warn {
  color: var(--warning);
}

.grid {
  display: grid;
  gap: 18px;
}

.grid.two {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0;
  font-size: 17px;
}

.panel-body {
  padding: 18px;
}

.form-grid {
  display: grid;
  gap: 14px;
}

.form-grid.two {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.field {
  display: grid;
  gap: 7px;
}

.field > span,
.check span {
  color: #354052;
  font-size: 13px;
  font-weight: 600;
}

input,
textarea,
select {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #ccd4df;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 110px;
  line-height: 1.65;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(45, 108, 223, 0.12);
}

.check {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.check input {
  width: 16px;
  min-height: 16px;
}

.image-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 8px;
}

.image-field input[type="file"] {
  display: none;
}

.rich-toolbar input[type="file"] {
  display: none;
}

.image-preview {
  width: 100%;
  height: 84px;
  margin-top: 8px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: #f7f8fa;
}

.rich-field {
  display: grid;
  gap: 8px;
}

.rich-label {
  color: #354052;
  font-size: 13px;
  font-weight: 700;
}

.rich-help {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.rich-field .tox.tox-tinymce {
  border: 1px solid #ccd4df;
  border-radius: 0;
}

.rich-field .tox .tox-edit-area::before {
  border: 2px solid rgba(45, 108, 223, 0.2);
}

.rich-field .tox-statusbar {
  border-top: 1px solid var(--line);
}

.rich-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  background: #f7f9fb;
  border: 1px solid #ccd4df;
  border-bottom: 0;
}

.rich-toolbar .button {
  background: #fff;
}

.rich-toolbar .button.active {
  border-color: var(--accent);
  color: var(--accent);
}

.rich-symbol {
  width: 34px;
  padding: 0;
}

.rich-editor-body,
.rich-source {
  min-height: 420px;
  width: 100%;
  padding: 18px 20px;
  color: #202733;
  background: #fff;
  border: 1px solid #ccd4df;
  outline: none;
  line-height: 1.85;
}

.rich-editor-body {
  overflow: auto;
  font-size: 16px;
  line-height: 1.9;
}

.rich-editor-body:focus,
.rich-source:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(45, 108, 223, 0.12);
}

.rich-editor-body p {
  margin: 0 0 1em;
}

.rich-editor-body h1,
.rich-editor-body h2,
.rich-editor-body h3,
.rich-editor-body h4 {
  margin: 1.2em 0 0.6em;
  line-height: 1.35;
}

.rich-editor-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 18px auto;
}

.rich-editor-body figure {
  margin: 18px 0;
}

.rich-editor-body figcaption {
  min-height: 24px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.rich-editor-body blockquote {
  margin: 16px 0;
  padding: 10px 14px;
  border-left: 4px solid var(--accent);
  background: #fff6f7;
}

.rich-editor-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
}

.rich-editor-body td,
.rich-editor-body th {
  border: 1px solid var(--line);
  padding: 8px;
}

.repeater {
  display: grid;
  gap: 12px;
}

.repeat-row {
  border: 1px solid var(--line);
  background: #fbfcfd;
}

.repeat-head {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.repeat-body {
  padding: 12px;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  border-bottom: 1px solid var(--line);
  padding: 11px 10px;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

.table th {
  color: var(--muted);
  background: #fbfcfd;
  font-size: 12px;
  font-weight: 700;
}

.table tr {
  cursor: pointer;
}

.table tr:hover,
.table tr.active {
  background: #fff6f7;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  color: #5a2630;
  background: #fae8eb;
  border: 1px solid #f2cbd1;
  font-size: 12px;
}

.pill.ok {
  color: #0f6848;
  background: #e6f5ee;
  border-color: #c4e5d4;
}

.pill.neutral {
  color: #445064;
  background: #eef2f6;
  border-color: #d8e0ea;
}

.muted {
  color: var(--muted);
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(150px, 0.9fr) minmax(130px, 0.75fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.field.compact {
  gap: 5px;
}

.field.compact input,
.field.compact select {
  min-height: 34px;
}

.table-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.pager {
  display: inline-flex;
  gap: 8px;
  flex: 0 0 auto;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.meta-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  color: #445064;
  background: #f7f9fb;
  border: 1px solid var(--line);
  font-size: 13px;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.category-card {
  display: grid;
  gap: 0;
  border: 1px solid var(--line);
  background: #fff;
}

.category-card button {
  display: grid;
  gap: 5px;
  min-height: 112px;
  padding: 14px;
  color: var(--ink);
  background: #fff;
  border: 0;
  text-align: left;
}

.category-card button:hover {
  background: #fff6f7;
}

.category-card span {
  color: #354052;
  font-weight: 700;
}

.category-card strong {
  font-size: 28px;
  line-height: 1;
}

.category-card em {
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}

.category-card a {
  display: flex;
  align-items: center;
  min-height: 34px;
  padding: 0 14px;
  color: var(--accent);
  border-top: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
}

.split {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(0, 1.25fr);
  gap: 18px;
  align-items: start;
}

.scroll-box {
  max-height: calc(100vh - 210px);
  overflow: auto;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric {
  padding: 18px;
  background: #fff;
  border: 1px solid var(--line);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.empty {
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1040px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .sidebar-footer {
    grid-template-columns: 1fr 1fr;
  }

  .main {
    padding: 22px 18px 42px;
  }

  .split,
  .grid.two,
  .form-grid.two,
  .metrics,
  .category-grid,
  .filter-bar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .topbar {
    flex-direction: column;
  }

  .nav {
    grid-template-columns: 1fr 1fr;
  }

  .image-field {
    grid-template-columns: 1fr;
  }
}
