*,
*::before,
*::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background: #f3f4f7;
  color: #222;
  font-size: 14px;
  line-height: 1.6;
}

a { color: #8e0c12; text-decoration: none; }
a:hover { text-decoration: underline; }

.admin-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.admin-side {
  background: linear-gradient(180deg, #7a0a10 0%, #8e0c12 40%, #6b080d 100%);
  color: #fff;
  padding: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.admin-side h2 {
  margin: 0;
  padding: 22px 20px 16px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .04em;
  border-bottom: 1px solid rgba(255,255,255,.12);
}

.admin-side a {
  display: block;
  padding: 9px 20px;
  color: #ffd6d6;
  text-decoration: none;
  font-size: 13px;
  border-left: 3px solid transparent;
}

.admin-side a:hover,
.admin-side a.on {
  background: rgba(255,255,255,.1);
  color: #fff;
  text-decoration: none;
}

.admin-side a.on {
  background: #b10f16;
  border-left-color: #ffd24a;
}

.admin-side a:last-child,
.admin-side a:nth-last-child(2) {
  color: #fff;
  opacity: .85;
}

.admin-main {
  padding: 28px 32px 48px;
  min-width: 0;
}

.admin-main h1 {
  margin: 0 0 18px;
  font-size: 22px;
  font-weight: 700;
}

.admin-main h2 {
  margin: 28px 0 12px;
  font-size: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e8e8ee;
}

.admin-main h3 {
  margin: 22px 0 10px;
  font-size: 15px;
}

.admin-main > p {
  color: #555;
  max-width: 860px;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
select,
textarea {
  width: 100%;
  max-width: 720px;
  display: block;
  padding: 8px 10px;
  border: 1px solid #d8d8e0;
  border-radius: 6px;
  background: #fff;
  font: inherit;
  color: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #c0121a;
  box-shadow: 0 0 0 3px rgba(215, 20, 28, .12);
}

input[type="file"] {
  display: block;
  margin: 4px 0 8px;
  max-width: 720px;
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  margin-right: 6px;
  vertical-align: middle;
}

textarea { min-height: 100px; resize: vertical; }
body.admin-editor .admin-main {
  padding: 12px 16px 32px;
}

body.admin-editor .form-card.editor-wide,
body.admin-editor .edit-panel.editor-wide,
body.admin-editor form.editor-wide {
  max-width: none;
  width: 100%;
}

body.admin-editor input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
body.admin-editor select,
body.admin-editor textarea {
  max-width: none;
}

textarea.rich-editor { min-height: calc(100vh - 40px); max-width: none; width: 100%; }

.tox-tinymce {
  margin-bottom: 16px;
  max-width: none !important;
  width: 100% !important;
  min-height: calc(100vh - 40px) !important;
}

label {
  display: block;
  margin: 12px 0 5px;
  font-weight: 600;
  color: #333;
  font-size: 13px;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  max-width: 960px;
}

.grid2 input,
.grid2 select,
.grid2 textarea { max-width: none; }

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(20, 20, 40, .04);
}

th, td {
  border-bottom: 1px solid #eee;
  padding: 10px 12px;
  text-align: left;
  font-size: 13px;
  vertical-align: middle;
}

th { background: #fafafa; font-weight: 700; color: #444; }

tr:last-child td { border-bottom: 0; }

td form { margin: 0; display: inline-block; vertical-align: middle; }

table input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
table select {
  max-width: 100%;
  width: 100%;
}

.btn {
  display: inline-block;
  background: #d7141c;
  color: #fff !important;
  border: 0;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  line-height: 1.3;
  text-decoration: none !important;
  vertical-align: middle;
}

.btn:hover { background: #b10f16; }

.btn.gray { background: #6b6f7a; }
.btn.gray:hover { background: #555860; }

td .btn { padding: 5px 10px; font-size: 12px; margin: 0 2px 2px 0; }

.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat {
  background: #fff;
  padding: 16px 18px;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(20, 20, 40, .06);
}

.stat span { color: #777; font-size: 13px; }
.stat b { display: block; font-size: 28px; color: #d7141c; margin-top: 4px; }

.alert {
  background: #eaf7ea;
  color: #1d6b2a;
  padding: 10px 14px;
  margin-bottom: 16px;
  border-radius: 6px;
  border: 1px solid #cde8cd;
}

.login-box {
  max-width: 400px;
  margin: 14vh auto;
  background: #fff;
  padding: 32px 36px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(20, 20, 40, .08);
}

.login-box h1 {
  margin: 0 0 18px;
  font-size: 22px;
  color: #8e0c12;
}

.login-box input { max-width: none; }

.login-box .btn { width: 100%; padding: 10px; margin-top: 8px; }

img.thumb {
  height: 80px;
  width: auto;
  max-width: 240px;
  object-fit: contain;
  background: #fafafa;
  border: 1px solid #eee;
  border-radius: 6px;
  vertical-align: middle;
  cursor: zoom-in;
}

.thumb-link {
  display: inline-block;
  line-height: 0;
  position: relative;
}

.thumb-empty { color: #999; font-size: 12px; }

.upload-preview-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 6px 0 10px;
}

.upload-preview-wrap .thumb {
  height: 96px;
  max-width: 280px;
}

#admin-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,.8);
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  padding: 24px;
}

#admin-lightbox.on { display: flex; }

#admin-lightbox img {
  max-width: 92vw;
  max-height: 92vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0,0,0,.45);
  cursor: default;
}

form > p { margin-top: 16px; }

.form-card,
.edit-panel {
  background: #fff;
  border-radius: 10px;
  padding: 8px 20px 16px;
  margin: 14px 0 28px;
  max-width: 760px;
  box-shadow: 0 1px 3px rgba(20, 20, 40, .05);
  scroll-margin-top: 16px;
}

.form-card.editor-wide,
.edit-panel.editor-wide,
form.editor-wide {
  max-width: none;
  width: 100%;
}

.edit-panel {
  border: 2px solid #d7141c;
  box-shadow: 0 0 0 4px rgba(215, 20, 28, .08);
}

.edit-panel h2,
.form-card h2 {
  margin: 12px 0 8px;
  border: 0;
  padding: 0;
  color: #8e0c12;
}

.hint {
  color: #8e0c12;
  font-size: 13px;
  margin: 0 0 8px;
}

@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-side { position: relative; height: auto; }
  .cards, .grid2 { grid-template-columns: 1fr; }
  .admin-main { padding: 16px; }
  table { display: block; overflow-x: auto; }
}
