:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #18202a;
  --muted: #6b7280;
  --line: #dfe4ea;
  --primary: #176b5b;
  --primary-dark: #0f5145;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
}

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

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

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  color: var(--text);
}

textarea {
  min-height: 110px;
  padding-top: 10px;
  resize: vertical;
}

.hidden {
  display: none !important;
}

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

.login-panel {
  width: min(420px, 100%);
  padding: 32px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.form {
  display: grid;
  gap: 16px;
}

.form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.error {
  min-height: 22px;
  color: var(--danger);
}

.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px;
  background: #13201d;
  color: #fff;
}

.brand {
  display: grid;
  gap: 6px;
}

.brand strong {
  font-size: 20px;
}

.brand span {
  color: #a8b3b0;
  font-size: 13px;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-button,
.ghost-button {
  justify-content: flex-start;
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  color: #d7dfdc;
  text-align: left;
}

.nav-button:hover,
.nav-button.active {
  background: #243532;
}

.ghost-button {
  margin-top: auto;
  border-color: #40514d;
}

.content {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

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

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

.secondary-button {
  background: #e9efed;
  color: var(--primary-dark);
}

.secondary-button:hover {
  background: #dce6e2;
}

.view {
  display: grid;
  gap: 16px;
}

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

.admin-form {
  display: grid;
  max-width: 720px;
  gap: 14px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.admin-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.admin-form button {
  width: 140px;
}

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

.toolbar select {
  width: 180px;
}

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

.stat-card {
  display: grid;
  gap: 8px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.stat-value {
  font-size: 30px;
  line-height: 1;
}

.stat-helper {
  color: var(--muted);
  font-size: 13px;
}

.compact-stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dark-card {
  background: linear-gradient(145deg, #151515 0%, #252525 100%);
  border-color: rgba(255, 214, 138, .28);
  color: #fff4d6;
}

.gold-card {
  background: linear-gradient(145deg, #fff8dd 0%, #f4c672 45%, #fff1c6 100%);
  border-color: rgba(214, 151, 37, .24);
}

.dark-card .stat-label,
.dark-card .stat-helper {
  color: rgba(255, 244, 214, .76);
}

.dark-card .stat-value {
  color: #fff4d6;
}

.gold-card .stat-label,
.gold-card .stat-helper {
  color: #6f4a14;
}

.gold-card .stat-value {
  color: #111827;
}

.auto-push-form {
  max-width: 820px;
}

.form-hint {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.table-wrap {
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 840px;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  background: #f9fafb;
}

td {
  font-size: 14px;
}

tr:last-child td {
  border-bottom: 0;
}

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

.link-cell {
  max-width: 320px;
  word-break: break-all;
}

.content-cell {
  max-width: 420px;
  white-space: pre-wrap;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

.small-select {
  width: 110px;
  min-height: 30px;
  padding: 0 8px;
  font-size: 13px;
}

.danger-button {
  background: var(--danger);
}

.danger-button:hover {
  background: #8f1d14;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: 360px;
  padding: 12px 16px;
  background: #111827;
  color: #fff;
  border-radius: 6px;
  box-shadow: 0 12px 30px rgba(0,0,0,.18);
}

.media-summary {
  display: flex;
  align-items: center;
  gap: 10px;
}

.thumb {
  width: 72px;
  height: 54px;
  object-fit: cover;
  border-radius: 6px;
  background: #eef0f3;
  border: 1px solid var(--line);
}

.empty-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(17, 24, 39, .46);
}

.modal-panel {
  width: min(920px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: var(--panel);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .22);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  margin: 0 0 6px;
  font-size: 22px;
}

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

.modal-body {
  display: grid;
  gap: 20px;
  padding: 22px 24px;
}

.modal-section h3 {
  margin: 0 0 10px;
  font-size: 15px;
  color: var(--muted);
}

.modal-section p {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.7;
}

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

.media-preview-grid img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.video-preview-list {
  display: grid;
  gap: 12px;
}

.video-preview-list video {
  width: min(520px, 100%);
  max-height: 320px;
  border-radius: 8px;
  background: #111827;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px 22px;
  border-top: 1px solid var(--line);
}

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

  .sidebar {
    position: static;
  }

  .topbar,
  .toolbar,
  .form-grid {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .toolbar select {
    width: 100%;
  }

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