:root {
  --bg: #f7f1e9;
  --surface: #fffaf4;
  --surface-strong: #ffffff;
  --line: #eadfce;
  --text: #3d2a1d;
  --muted: #8a7766;
  --primary: #ff8f45;
  --primary-strong: #f46d2f;
  --green: #2f9e68;
  --blue: #3478f6;
  --red: #e5484d;
  --shadow: 0 18px 50px rgba(82, 51, 24, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

button {
  cursor: pointer;
}

button:disabled,
button[data-busy="true"] {
  cursor: not-allowed;
  opacity: 0.58;
}

button[data-busy="true"]::after {
  content: "";
  width: 12px;
  height: 12px;
  margin-left: 8px;
  display: inline-block;
  vertical-align: -2px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
  animation: button-spin 0.8s linear infinite;
}

@keyframes button-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  button[data-busy="true"]::after {
    animation: none;
  }
}

.hidden {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    radial-gradient(circle at 20% 15%, rgba(255, 143, 69, 0.18), transparent 34%),
    radial-gradient(circle at 80% 20%, rgba(126, 214, 166, 0.18), transparent 30%),
    var(--bg);
}

.login-panel {
  width: min(420px, 100%);
  padding: 38px 36px 36px;
  border: 1px solid rgba(255, 143, 69, 0.22);
  border-radius: 22px;
  background: rgba(255, 250, 244, 0.92);
  box-shadow: var(--shadow);
}

.login-brand {
  display: grid;
  justify-items: center;
  text-align: center;
}

.brand-badge {
  width: 82px;
  height: 82px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 24px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.94), rgba(255, 244, 232, 0.9));
  border: 1px solid rgba(255, 143, 69, 0.16);
  box-shadow:
    0 18px 34px rgba(244, 109, 47, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.brand-logo {
  width: 72px;
  height: 72px;
  display: block;
  border-radius: 20px;
  object-fit: cover;
}

.brand-badge.small {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 13px;
  box-shadow: 0 8px 18px rgba(244, 109, 47, 0.12);
}

.brand-logo.small {
  width: 34px;
  height: 34px;
  border-radius: 10px;
}

.login-panel h1 {
  margin: 18px 0 8px;
  font-size: 29px;
  letter-spacing: 0;
  line-height: 1.18;
}

.login-panel p,
.sidebar-brand span,
.eyebrow,
.muted {
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 16px;
  margin-top: 30px;
}

.login-form label,
.field {
  display: grid;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
}

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

textarea {
  min-height: 150px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 143, 69, 0.14);
}

.login-form button,
.primary-btn {
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
}

.primary-btn.compact {
  min-height: 36px;
  padding: 0 14px;
}

.ghost-btn.compact {
  min-height: 36px;
  padding: 0 14px;
}

.form-error {
  min-height: 20px;
  color: var(--red);
  font-size: 13px;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  border-right: 1px solid var(--line);
  background: #fff8ef;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 20px;
  min-width: 0;
  white-space: nowrap;
}

.sidebar-brand strong,
.sidebar-brand span {
  display: block;
}

.sidebar-brand-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
  line-height: 1.18;
}

.sidebar-brand-copy strong,
.sidebar-brand-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.nav-btn {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 10px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  font-weight: 700;
}

.nav-btn.active {
  color: var(--primary-strong);
  background: #fff0e4;
}

.nav-icon {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  color: var(--primary-strong);
  background: #fff;
  border: 1px solid rgba(255, 143, 69, 0.24);
}

.nav-icon svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  display: block;
}

.nav-btn.active .nav-icon {
  color: #fff;
  background: var(--primary-strong);
  border-color: var(--primary-strong);
  box-shadow: 0 8px 18px rgba(244, 109, 47, 0.22);
}

.workspace {
  min-width: 0;
  padding: 24px;
}

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

.topbar h2 {
  margin: 4px 0 0;
  font-size: 28px;
}

.eyebrow {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
}

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

.admin-pill,
.tag,
.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
  background: #fff;
  border: 1px solid var(--line);
}

.tag.soft {
  min-height: 24px;
  margin-left: 8px;
  color: var(--muted);
  background: #fffaf4;
  font-size: 11px;
}

.ghost-btn,
.danger-btn,
.table-btn {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
  font-weight: 700;
}

.icon-btn {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
  font-weight: 800;
}

.icon-btn.danger {
  color: var(--red);
  border-color: #ffd0d2;
  background: #fff8f8;
}

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

.table-btn.danger {
  color: var(--red);
  border-color: #ffd0d2;
  background: #fff8f8;
}

td .table-btn + .table-btn {
  margin-left: 6px;
}

.notice {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  color: var(--primary-strong);
  background: #fff0e4;
  border: 1px solid #ffd9bd;
  font-weight: 700;
}

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

.stat-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-strong);
  box-shadow: 0 10px 30px rgba(82, 51, 24, 0.06);
}

.stat-card {
  position: relative;
  min-height: 112px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  overflow: hidden;
  padding: 18px 20px;
}

.stat-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.stat-card small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.stat-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 15px;
  color: var(--primary-strong);
  background: linear-gradient(135deg, #fff2e6, #fffaf4);
  border: 1px solid rgba(255, 143, 69, 0.24);
  font-style: normal;
}

.stat-icon svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

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

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

.panel-head h3 {
  margin: 0;
  font-size: 18px;
}

.panel-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 12px;
}

.filters {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.filters input,
.filters select {
  width: 220px;
}

.filter-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.filter-actions {
  display: flex;
  gap: 8px;
  min-height: 42px;
  align-items: center;
}

.platform-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.platform-tab {
  min-height: 66px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  color: var(--text);
  background: #fffaf4;
  text-align: left;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.platform-tab:hover,
.platform-tab.active {
  transform: translateY(-1px);
  border-color: rgba(255, 143, 69, 0.55);
  box-shadow: 0 12px 26px rgba(82, 51, 24, 0.08);
}

.platform-tab.active {
  background: linear-gradient(135deg, #fff3e6, #fffaf4);
}

.platform-tab strong,
.platform-tab small {
  display: block;
}

.platform-tab small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.platform-mark {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 11px;
  color: #fff;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), #ffc070);
  box-shadow: 0 8px 18px rgba(244, 109, 47, 0.18);
}

.platform-mark.large {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  font-size: 18px;
}

.ad-platform-panel {
  background: linear-gradient(135deg, #fff9f1, #ffffff);
}

.ad-platform-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

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

.platform-title h3 {
  margin: 0;
  font-size: 20px;
}

.platform-title p {
  margin: 3px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.ad-platform-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.ad-platform-meta span,
.ad-editor-note {
  border: 1px solid #f2dfc8;
  border-radius: 10px;
  color: var(--muted);
  background: #fffaf4;
  font-size: 13px;
  font-weight: 700;
}

.ad-platform-meta span {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
}

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

.ad-type-card {
  min-height: 118px;
  display: grid;
  align-content: space-between;
  gap: 12px;
  border: 1px solid #f0e1ce;
  border-radius: 14px;
  padding: 14px;
  background: #fff;
}

.ad-type-card strong {
  display: block;
  margin-bottom: 6px;
}

.ad-type-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.ad-editor-note {
  padding: 12px 14px;
  margin-bottom: 14px;
  line-height: 1.6;
}

.content-module-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.content-module-card {
  min-height: 128px;
  display: grid;
  align-content: space-between;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  color: var(--text);
  background: #fffaf4;
  text-align: left;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.content-module-card:hover,
.content-module-card.active {
  transform: translateY(-1px);
  border-color: rgba(255, 143, 69, 0.55);
  box-shadow: 0 12px 26px rgba(82, 51, 24, 0.08);
}

.content-module-card.active {
  background: linear-gradient(135deg, #fff0e4, #fffaf4);
}

.content-module-card strong,
.content-module-card span,
.content-module-card small {
  display: block;
}

.content-module-card strong {
  font-size: 16px;
}

.content-module-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.content-module-card small {
  color: var(--primary-strong);
  font-weight: 800;
}

.content-workbench .panel-head p {
  margin: 4px 0 0;
}

.upload-box {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 180px minmax(240px, 1.4fr) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid #f0e3d2;
  border-radius: 12px;
  background: #fffaf4;
}

.upload-box strong {
  display: block;
  margin-bottom: 4px;
}

.upload-box p {
  margin: 0;
  line-height: 1.5;
}

.upload-file input {
  padding-top: 8px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
  background: #fff;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid #f0e7da;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  color: var(--muted);
  background: #fffaf4;
  font-size: 12px;
}

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

.status.on {
  color: var(--green);
  border-color: #bde9d1;
  background: #effaf4;
}

.status.off,
.status.pending {
  color: var(--red);
  border-color: #ffd0d2;
  background: #fff3f3;
}

.status.processing {
  color: var(--blue);
  border-color: #c9dbff;
  background: #f1f6ff;
}

.status.done {
  color: var(--green);
  border-color: #bde9d1;
  background: #effaf4;
}

.split-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

.editor-grid .wide {
  grid-column: 1 / -1;
}

.repeat-section {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #f0e3d2;
  border-radius: 14px;
  background: #fffaf4;
}

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

.repeat-section h4 {
  margin: 0;
  font-size: 15px;
}

.repeat-section p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.repeat-list {
  display: grid;
  gap: 10px;
}

.repeat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto;
  gap: 10px;
  align-items: end;
}

.repeat-row.score-row {
  grid-template-columns: minmax(0, 1fr) 110px minmax(0, 1fr) auto;
}

.repeat-row label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

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

.detail-item {
  min-height: 70px;
  padding: 12px;
  border: 1px solid #f0e3d2;
  border-radius: 12px;
  background: #fffaf4;
}

.detail-item span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.detail-item strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

.detail-section {
  margin-top: 18px;
}

.detail-section h4 {
  margin: 0 0 10px;
  font-size: 15px;
}

.json-preview {
  max-height: 320px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  border: 1px solid #f0e3d2;
  border-radius: 12px;
  background: #201915;
  color: #fff4e8;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.long-text-preview {
  padding: 14px;
  border: 1px solid #f0e3d2;
  border-radius: 12px;
  background: #fffaf4;
  color: var(--text);
  font-size: 14px;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.setting-field small {
  color: var(--muted);
  font-weight: 500;
  line-height: 1.5;
}

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

@media (max-width: 1360px) {
  .platform-tabs,
  .content-module-grid,
  .ad-type-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .stats-grid,
  .split-grid,
  .settings-grid,
  .detail-grid,
  .repeat-row,
  .repeat-row.score-row,
  .platform-tabs,
  .ad-type-grid,
  .upload-box {
    grid-template-columns: 1fr;
  }

  .repeat-section-head {
    display: grid;
  }

  .content-module-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}
