:root {
  --navy: #0e1830;
  --navy-soft: #16233f;
  --blue: #1e6fff;
  --blue-dark: #1557cc;
  --gold: #e8b04b;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1b2536;
  --text-muted: #7d8998;
  --danger: #d64545;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(14, 24, 48, 0.08), 0 6px 20px rgba(14, 24, 48, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB",
    "Source Han Sans SC", "Noto Sans CJK SC", "Heiti SC", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.mono {
  font-family: Consolas, "Courier New", monospace;
}

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

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 24px;
  background: var(--navy);
  color: #fff;
}

.brand {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.brand::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 10px;
  border-radius: 2px;
  background: var(--gold);
  vertical-align: middle;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.username {
  color: #c9d3e0;
  font-size: 13px;
}

.logout-form {
  margin: 0;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 7px 16px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  line-height: 1.4;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
  text-decoration: none;
}

.btn-primary {
  background: var(--blue);
  color: #fff;
}

.btn-primary:hover {
  background: var(--blue-dark);
}

.btn-ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.35);
  color: #fff;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-block {
  display: block;
  width: 100%;
  padding: 10px 16px;
  font-size: 14px;
}

/* ---------- Layout ---------- */
.layout {
  display: flex;
  min-height: calc(100vh - 56px);
}

.sidebar {
  width: 200px;
  flex: 0 0 200px;
  background: var(--navy-soft);
  padding: 16px 12px;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.menu-item {
  display: block;
  padding: 9px 14px;
  border-radius: 6px;
  color: #c9d3e0;
  font-size: 14px;
}

.menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  text-decoration: none;
}

.menu-item.active {
  background: var(--blue);
  color: #fff;
  font-weight: 600;
}

.content {
  flex: 1 1 auto;
  min-width: 0;
  padding: 28px 32px 48px;
}

/* ---------- Pages ---------- */
.page-title {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 700;
}

.page-subtitle {
  margin: 0 0 24px;
  color: var(--text-muted);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: inherit;
}

.card:hover {
  border-color: var(--blue);
  text-decoration: none;
}

.card-label {
  color: var(--text-muted);
  font-size: 13px;
}

.card-value {
  font-size: 30px;
  font-weight: 700;
  color: var(--navy);
}

.panel {
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-title {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 700;
}

/* ---------- Login ---------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0e1830 0%, #16233f 55%, #1e6fff 160%);
}

.login-card {
  width: 340px;
  padding: 34px 32px 36px;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(4, 16, 31, 0.4);
}

.login-brand {
  color: var(--gold);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
}

.login-title {
  margin: 6px 0 22px;
  font-size: 20px;
  font-weight: 700;
}

.login-error {
  margin: 0 0 16px;
  padding: 9px 12px;
  border: 1px solid #f2c7c7;
  border-radius: 6px;
  background: #fdf3f3;
  color: var(--danger);
  font-size: 13px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 13px;
  color: var(--text-muted);
}

.field input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
}

.field input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(30, 111, 255, 0.12);
}

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.toolbar-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.toolbar-spacer {
  flex: 1 1 auto;
}

.filter-links {
  display: inline-flex;
  gap: 4px;
}

.filter-link {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
}

.filter-link:hover {
  border-color: var(--blue);
  color: var(--blue);
  text-decoration: none;
}

.filter-link.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  font-weight: 600;
}

.input {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
}

.input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(30, 111, 255, 0.12);
}

/* ---------- Buttons (extra) ---------- */
.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #b93636;
}

.btn-secondary {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.inline-form {
  display: inline;
  margin: 0;
}

/* ---------- Table ---------- */
.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th,
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.table th {
  background: #f7f9fc;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background: #f9fbff;
}

.col-actions {
  white-space: nowrap;
}

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

.thumb {
  display: block;
  width: 44px;
  height: 44px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.thumb-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px dashed var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 11px;
}

/* ---------- Badge ---------- */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.6;
  white-space: nowrap;
}

.badge-on {
  background: #e8f6ee;
  color: #1f8a4c;
  border: 1px solid #bfe6cf;
}

.badge-off {
  background: #fdeeee;
  color: var(--danger);
  border: 1px solid #f2c7c7;
}

.badge-cat {
  background: #eef3ff;
  color: var(--blue-dark);
  border: 1px solid #cdddfb;
}

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
}

.page-link {
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
}

.page-link:hover {
  border-color: var(--blue);
  color: var(--blue);
  text-decoration: none;
}

.page-link.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  font-weight: 600;
}

.page-link.disabled {
  color: #c3cbd6;
  pointer-events: none;
}

.pagination-info {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 13px;
}

/* ---------- Forms (products) ---------- */
.form-panel {
  max-width: 760px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.form-grid .field-full {
  grid-column: 1 / -1;
}

.form .field select,
.form .field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
}

.form .field select:focus,
.form .field textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(30, 111, 255, 0.12);
}

.form .field textarea {
  min-height: 96px;
  resize: vertical;
}

.field-hint {
  color: var(--text-muted);
  font-size: 12px;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}

.form-error {
  margin: 0 0 18px;
  padding: 9px 12px;
  border: 1px solid #f2c7c7;
  border-radius: 6px;
  background: #fdf3f3;
  color: var(--danger);
  font-size: 13px;
}

.image-preview {
  display: block;
  max-width: 220px;
  max-height: 160px;
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

/* ---------- Media library ---------- */
.field-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.field-inline .field-label {
  white-space: nowrap;
}

.upload-status {
  font-size: 13px;
  color: var(--text-muted);
}

.upload-status.pending {
  color: var(--blue);
}

.upload-status.ok {
  color: #1f8a4c;
}

.upload-status.error {
  color: var(--danger);
}

.dropzone {
  margin-bottom: 20px;
  padding: 26px 20px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--blue);
  background: #f4f8ff;
}

.dropzone-text {
  margin: 0;
  font-size: 14px;
  color: var(--text);
}

.dropzone-hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.media-empty {
  padding: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
  color: var(--text-muted);
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.media-card {
  display: flex;
  flex-direction: column;
  margin: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.media-thumb-link {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 150px;
  background: #f7f9fc;
  border-bottom: 1px solid var(--border);
}

.media-thumb {
  display: block;
  width: 100%;
  height: 150px;
  object-fit: contain;
}

.media-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
}

.media-name {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.media-path {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #f7f9fc;
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

/* ---------- Rich text editor ---------- */
.form-panel-wide {
  max-width: 920px;
}

.rte {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.rte-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  background: #f7f9fc;
}

.rte-group {
  display: inline-flex;
  gap: 4px;
  padding-right: 6px;
  border-right: 1px solid var(--border);
}

.rte-group:last-child {
  padding-right: 0;
  border-right: 0;
}

.rte-btn {
  padding: 4px 11px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease,
    background 0.15s ease;
}

.rte-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.rte-btn.active {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.rte-btn-danger {
  color: var(--danger);
}

.rte-btn-danger:hover {
  border-color: var(--danger);
  color: #fff;
  background: var(--danger);
}

/* ---------- 图片工具条 ---------- */
.rte-imagebar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  background: #eef3ff;
}

.rte-imagebar__label {
  font-size: 12px;
  font-weight: 700;
  color: var(--blue-dark);
}

.rte-imagebar__group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.rte-imagebar__group-label {
  font-size: 12px;
  color: var(--text-muted);
}

.rte-editor {
  min-height: 320px;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.8;
  outline: none;
}

.rte-editor:focus {
  box-shadow: inset 0 0 0 2px rgba(30, 111, 255, 0.12);
}

.rte-editor p {
  margin: 0.5em 0;
}

.rte-editor h2,
.rte-editor h3 {
  margin: 0.6em 0 0.4em;
}

.rte-editor ul,
.rte-editor ol {
  padding-left: 22px;
}

.rte-editor blockquote {
  margin: 0.6em 0;
  padding: 6px 14px;
  border-left: 3px solid var(--blue);
  background: #f4f8ff;
  color: #42506a;
}

.rte-editor img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

/* 后台所见 = 前台所出：尺寸档位与对齐在编辑器内即时预览 */
.rte-editor img.img-sm {
  width: 25%;
}

.rte-editor img.img-md {
  width: 50%;
}

.rte-editor img.img-lg {
  width: 75%;
}

.rte-editor img.img-full {
  width: 100%;
}

.rte-editor img.align-left {
  margin-left: 0;
  margin-right: auto;
}

.rte-editor img.align-center {
  margin-left: auto;
  margin-right: auto;
}

.rte-editor img.align-right {
  margin-left: auto;
  margin-right: 0;
}

.rte-editor img.rte-img-selected {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  cursor: pointer;
}

.rte-resize-handle {
  position: absolute;
  z-index: 20;
  width: 14px;
  height: 14px;
  margin: 0;
  border: 2px solid #fff;
  border-radius: 3px;
  background: var(--blue);
  box-shadow: 0 0 0 1px var(--blue-dark);
  cursor: ew-resize;
  transform: translate(-7px, -7px);
}

.rte-editor p.text-center {
  text-align: center;
}

.rte-editor p.text-right {
  text-align: right;
}

/* ---------- Detail pages ---------- */
.detail-panel {
  max-width: 860px;
}

.detail-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 24px;
  margin-bottom: 18px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.detail-label {
  color: var(--text-muted);
  font-size: 12px;
}

.detail-value {
  font-size: 14px;
}

.detail-message {
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f7f9fc;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.badge-pending {
  background: #fff4e5;
  color: #b26a00;
  border: 1px solid #f3d9ad;
}

.badge-done {
  background: #e8f6ee;
  color: #1f8a4c;
  border: 1px solid #bfe6cf;
}

/* ---------- Settings ---------- */
.settings-group + .settings-group {
  margin-top: 24px;
}

.settings-group-title {
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  font-weight: 700;
  color: var(--navy);
}

.form-ok {
  margin: 0 0 18px;
  padding: 9px 12px;
  border: 1px solid #bfe6cf;
  border-radius: 6px;
  background: #e8f6ee;
  color: #1f8a4c;
  font-size: 13px;
}

/* ---------- Publish ---------- */
.publish-panel {
  margin-bottom: 20px;
}

.publish-status {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px 24px;
  margin-bottom: 18px;
}

.build-log {
  max-height: 460px;
  margin: 0;
  padding: 14px 16px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0e1830;
  color: #d7e0ef;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}



/* 富文本编辑器内的表格预览 */
.rte-editor table{width:100%;border-collapse:collapse;margin:12px 0}
.rte-editor th,.rte-editor td{border:1px solid #c9a45c66;padding:8px 10px}
.rte-editor thead th{background:rgba(195,164,92,.12);font-weight:600}
