:root {
  --bg: #f5efe6;
  --bg-strong: #fffdf9;
  --card: rgba(255, 255, 255, 0.88);
  --line: rgba(78, 57, 35, 0.12);
  --text: #17120f;
  --muted: #766758;
  --accent: #9d4b24;
  --accent-strong: #7d3818;
  --danger: #a13f34;
  --success: #3d7a5f;
  --warning: #9c6d22;
  --shadow: 0 14px 32px rgba(88, 61, 33, 0.09);
  --shadow-soft: 0 8px 22px rgba(88, 61, 33, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(194, 134, 70, 0.12), transparent 24%),
    linear-gradient(180deg, #faf5ee 0%, #f3ebdf 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(96, 72, 47, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(96, 72, 47, 0.03) 1px, transparent 1px);
  background-size: 28px 28px;
}

.admin-shell {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 18px 36px;
}

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

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
}

.admin-topbar h1 {
  margin: 0;
  font-size: 1.6rem;
  line-height: 1.2;
}

.subtext {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.primary-btn,
.ghost-btn,
.danger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  padding: 11px 16px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
}

.primary-btn {
  border: 0;
  color: #fff7ef;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: var(--shadow-soft);
}

.ghost-btn {
  border: 1px solid rgba(82, 60, 36, 0.1);
  color: var(--text);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-soft);
}

.danger-btn {
  border: 0;
  color: #fff4f2;
  background: var(--danger);
}

.primary-btn:hover,
.ghost-btn:hover,
.danger-btn:hover {
  transform: translateY(-1px);
}

.primary-btn:disabled,
.ghost-btn:disabled,
.danger-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

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

.stat-card,
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 18px 20px;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
}

.stat-card strong {
  display: block;
  margin-top: 10px;
  font-size: 1.7rem;
}

.panel {
  padding: 18px;
  margin-bottom: 16px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.08rem;
}

.panel-head p {
  margin: 8px 0 0;
  color: var(--muted);
}

.upload-form {
  display: grid;
  grid-template-columns: 1.2fr 1.4fr auto auto;
  gap: 12px;
  align-items: end;
}

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

.field span,
.check-field span {
  color: var(--muted);
  font-size: 0.92rem;
}

.field select,
.field input[type="file"] {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(85, 62, 36, 0.12);
  background: var(--bg-strong);
  color: var(--text);
  font: inherit;
}

.file-field input[type="file"] {
  padding-block: 10px;
}

.check-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  white-space: nowrap;
}

.status-panel {
  padding: 14px 16px;
  line-height: 1.65;
}

.status-panel.success {
  color: var(--success);
  background: rgba(67, 130, 102, 0.08);
  border-color: rgba(67, 130, 102, 0.18);
}

.status-panel.error {
  color: var(--danger);
  background: rgba(161, 63, 52, 0.08);
  border-color: rgba(161, 63, 52, 0.18);
}

.library-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.library-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(82, 60, 36, 0.1);
  box-shadow: var(--shadow-soft);
  color: var(--muted);
}

.library-chip strong {
  color: var(--text);
}

.library-sections {
  display: grid;
  gap: 14px;
}

.library-section {
  border: 1px solid rgba(82, 60, 36, 0.08);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.55);
  overflow: hidden;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(82, 60, 36, 0.08);
}

.section-head h3 {
  margin: 0;
  font-size: 1rem;
}

.section-head span {
  color: var(--muted);
  font-size: 0.9rem;
}

.file-list {
  display: grid;
}

.file-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid rgba(82, 60, 36, 0.08);
}

.file-item:first-child {
  border-top: 0;
}

.file-main {
  min-width: 0;
}

.file-name {
  margin: 0;
  font-size: 1rem;
  line-height: 1.45;
  word-break: break-word;
}

.file-meta {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.7;
}

.file-note {
  margin: 8px 0 0;
  color: var(--warning);
  font-size: 0.88rem;
  line-height: 1.65;
}

.file-actions {
  display: flex;
  align-items: center;
}

.library-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.library-badge,
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  line-height: 1;
}

.library-badge {
  color: var(--accent-strong);
  background: rgba(157, 75, 36, 0.1);
}

.status-badge.active {
  color: var(--success);
  background: rgba(61, 122, 95, 0.12);
}

.status-badge.excluded {
  color: var(--warning);
  background: rgba(156, 109, 34, 0.12);
}

.status-badge.unmanaged {
  color: var(--muted);
  background: rgba(90, 80, 70, 0.1);
}

.empty-box {
  padding: 18px 16px;
  color: var(--muted);
  line-height: 1.7;
}

@media (max-width: 980px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .upload-form {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .admin-shell {
    padding: 14px 12px 24px;
  }

  .admin-topbar,
  .panel-head {
    flex-direction: column;
  }

  .admin-topbar,
  .panel-head {
    align-items: stretch;
  }

  .file-item {
    grid-template-columns: 1fr;
  }

  .topbar-actions,
  .file-actions {
    width: 100%;
  }

  .topbar-actions {
    flex-direction: column;
  }

  .stats-grid,
  .upload-form {
    grid-template-columns: 1fr;
  }

  .file-actions .danger-btn {
    width: 100%;
  }
}
