:root {
  --bg: #f3f5f7;
  --ink: #18212f;
  --muted: #667085;
  --line: #d8dee8;
  --panel: #ffffff;
  --accent: #1677ff;
  --accent-dark: #0f5dcc;
  --ok: #16803c;
  --warn: #9a5a00;
  --bad: #b42318;
  --soft-ok: #e8f6ee;
  --soft-warn: #fff3dc;
  --soft-bad: #fee9e7;
  --shadow: 0 12px 34px rgba(24, 33, 47, 0.08);
}

* {
  box-sizing: border-box;
}

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

.topbar {
  min-height: 82px;
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: #202938;
  color: #fff;
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 750;
  letter-spacing: 0;
}

.topbar p {
  margin: 6px 0 0;
  color: #cdd5df;
  font-size: 13px;
}

.topbar-main {
  margin-left: clamp(18px, 5vw, 86px);
  display: flex;
  align-items: center;
  gap: 18px;
}

.top-links {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

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

.ghost-link {
  height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 6px;
  color: #fff;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}

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

.ghost-button {
  height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 6px;
  background: transparent;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.ghost-button:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.42);
}

.status-pill,
.risk {
  min-width: 82px;
  height: 32px;
  padding: 0 11px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
}

.status-pill {
  background: rgba(255, 255, 255, 0.13);
  color: #fff;
}

.status-pill.ok {
  background: var(--soft-ok);
  color: var(--ok);
}

.status-pill.warn {
  background: var(--soft-warn);
  color: var(--warn);
}

.status-pill.bad {
  background: var(--soft-bad);
  color: var(--bad);
}

.layout {
  padding: 22px 28px 32px;
  display: grid;
  gap: 18px;
  align-items: start;
}

.admin-layout {
  grid-template-columns: minmax(460px, 1fr) minmax(380px, 520px);
}

.public-page {
  width: min(920px, calc(100% - 28px));
  margin: 22px auto 34px;
  display: grid;
  gap: 16px;
}

.login-page {
  min-height: 100vh;
  padding: 22px;
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(22, 119, 255, 0.13), rgba(22, 128, 60, 0.08)),
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.95), rgba(243, 245, 247, 0) 42%),
    #eef2f7;
}

.login-panel {
  width: min(520px, 100%);
  padding: 34px;
  border: 1px solid rgba(216, 222, 232, 0.92);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 60px rgba(24, 33, 47, 0.14);
}

.login-brand {
  margin-bottom: 26px;
  text-align: center;
}

.brand-code {
  margin-bottom: 10px;
  padding: 5px 10px;
  border: 1px solid #d8e8ff;
  border-radius: 999px;
  background: #f4f9ff;
  color: var(--accent);
  display: inline-flex;
  gap: 1px;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
}

.login-panel h1 {
  margin: 0;
  font-size: 30px;
  text-align: center;
  letter-spacing: 0;
}

.login-title {
  display: flex;
  justify-content: center;
}

.jump-char {
  display: inline-block;
  animation: titleJump 520ms cubic-bezier(0.2, 0.82, 0.32, 1.2) both;
}

.brand-code .jump-char:nth-child(1) { animation-delay: 40ms; }
.brand-code .jump-char:nth-child(2) { animation-delay: 90ms; }
.brand-code .jump-char:nth-child(3) { animation-delay: 140ms; }
.brand-code .jump-char:nth-child(4) { animation-delay: 190ms; }
.brand-code .jump-char:nth-child(5) { animation-delay: 240ms; }
.brand-code .jump-char:nth-child(6) { animation-delay: 290ms; }
.brand-code .jump-char:nth-child(7) { animation-delay: 340ms; }
.login-title .jump-char:nth-child(1) { animation-delay: 430ms; }
.login-title .jump-char:nth-child(2) { animation-delay: 490ms; }
.login-title .jump-char:nth-child(3) { animation-delay: 550ms; }
.login-title .jump-char:nth-child(4) { animation-delay: 610ms; }
.login-title .jump-char:nth-child(5) { animation-delay: 670ms; }
.login-title .jump-char:nth-child(6) { animation-delay: 730ms; }

@keyframes titleJump {
  0% {
    opacity: 0;
    transform: translateY(14px) scale(0.96);
  }
  45% {
    opacity: 1;
    transform: translateY(-7px) scale(1.04);
  }
  72% {
    transform: translateY(2px) scale(0.99);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .jump-char {
    animation: none;
  }
}

.login-choice {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.login-choice-card {
  min-height: 112px;
  height: auto;
  padding: 18px 14px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  text-align: center;
}

.login-choice-card strong,
.login-choice-card span {
  display: block;
}

.login-choice-card strong {
  font-size: 18px;
}

.login-choice-card span {
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
  font-weight: 700;
}

.login-choice-card.advertiser {
  border-color: #c6e7d2;
  background: #fff;
  color: var(--ok);
}

.login-choice-card.advertiser:hover {
  background: var(--soft-ok);
  color: var(--ok);
  border-color: #91d5aa;
}

.login-choice-card.advertiser span {
  color: #3d8f5a;
}

.login-form {
  display: grid;
  gap: 12px;
}

.login-form[hidden] {
  display: none;
}

.login-error {
  color: var(--bad);
  font-size: 13px;
  font-weight: 700;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

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

.panel-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.compact-field {
  width: auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.compact-field input {
  width: 132px;
  height: 34px;
}

.bulk-toggle,
.submission-select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.bulk-toggle input,
.submission-select input {
  width: 16px;
  height: 16px;
  padding: 0;
}

.panel h2 {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0;
}

label,
.full-label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 13px;
  font-weight: 650;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cfd6e2;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input,
select {
  height: 40px;
  padding: 0 11px;
}

textarea {
  min-height: 104px;
  padding: 10px 11px;
  resize: vertical;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.14);
}

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

.full-label {
  margin-top: 12px;
}

.toolbar {
  margin-top: 14px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

button {
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

button:disabled {
  border-color: #cfd6e2;
  background: #e7ebf0;
  color: #8a95a5;
  cursor: not-allowed;
}

.secondary-button {
  border-color: #cfd6e2;
  background: #fff;
  color: #344054;
}

.secondary-button:hover {
  background: #edf4ff;
  color: var(--accent);
  border-color: #9cc8ff;
}

.danger-button {
  border-color: var(--bad);
  background: #fff;
  color: var(--bad);
}

.danger-button:hover {
  background: var(--soft-bad);
  border-color: var(--bad);
  color: var(--bad);
}

.icon-button {
  width: 36px;
  min-width: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: #344054;
  border-color: #cfd6e2;
}

.icon-button:hover {
  background: #edf4ff;
  color: var(--accent);
  border-color: #9cc8ff;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.customer-editor,
.submission-list {
  display: grid;
  gap: 10px;
}

.config-panel {
  grid-column: 1 / -1;
  scroll-margin-top: 18px;
}

.customer-row {
  display: grid;
  grid-template-columns: 44px minmax(220px, 1.2fr) minmax(360px, 1.6fr) 120px 82px 36px;
  gap: 8px;
  align-items: center;
}

.customer-row-head {
  padding: 0 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.customer-row.reviewed input {
  background: #eef1f5;
  color: #7b8492;
  border-color: #d7dde7;
}

.customer-select {
  justify-self: center;
}

.submission-card {
  width: 100%;
  height: auto;
  min-height: 62px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  display: grid;
  grid-template-columns: minmax(150px, 1.1fr) minmax(150px, 1fr) minmax(330px, auto);
  gap: 10px;
  align-items: center;
  text-align: left;
}

.submission-states {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.submission-states .risk {
  min-width: 72px;
  height: 28px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  text-align: center;
}

.profit-summary {
  margin: 2px 0 14px;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.profit-card {
  position: relative;
  overflow: hidden;
  min-height: 68px;
  padding: 11px 10px 10px 12px;
  border: 1px solid #dfe5ee;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(24, 33, 47, 0.05);
  display: grid;
  align-content: center;
  gap: 7px;
}

.profit-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: #a7b0bf;
}

.profit-card-primary {
  background: #f7fbff;
  border-color: #c9dcf8;
}

.profit-card-primary::before {
  background: var(--accent);
}

.profit-card-primary.finance {
  background: #f7fcf9;
  border-color: #c6e7d2;
}

.profit-card-primary.finance::before {
  background: var(--ok);
}

.profit-summary span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.profit-summary strong {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.profit-card-primary strong {
  font-size: 16px;
}

.danger-icon {
  color: var(--bad);
}

.danger-icon:hover {
  background: var(--soft-bad);
  border-color: #f0a7a1;
  color: var(--bad);
}

.review-toolbar {
  justify-content: flex-end;
}

.submission-card:hover,
.submission-card.active {
  border-color: var(--accent);
  background: #f7fbff;
}

.submission-card strong,
.submission-card span {
  display: block;
}

.submission-card span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

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

.metrics div {
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  display: grid;
  align-content: center;
  gap: 6px;
}

.metrics span {
  color: var(--muted);
  font-size: 12px;
}

.metrics strong {
  font-size: 20px;
  letter-spacing: 0;
}

.receipt-preview {
  min-height: 160px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
}

.detail-preview img,
.submit-preview img {
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  display: block;
}

.detail-preview a {
  width: 100%;
  display: block;
}

.submit-preview {
  min-height: 220px;
}

#channelMessage {
  min-height: 230px;
  font-size: 14px;
}

.checks {
  display: grid;
  gap: 8px;
}

.check {
  min-height: 36px;
  padding: 8px 10px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  font-weight: 650;
}

.check.ok,
.risk.ok {
  background: var(--soft-ok);
  color: var(--ok);
}

.check.warn,
.risk.warn {
  background: var(--soft-warn);
  color: var(--warn);
}

.check.bad,
.risk.bad {
  background: var(--soft-bad);
  color: var(--bad);
}

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

  .result-panel,
  .config-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .topbar {
    padding: 16px;
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-main {
    margin-left: 0;
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .top-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .top-links {
    width: 100%;
  }

  .layout {
    padding: 14px;
  }

  .admin-layout,
  .form-grid,
  .metrics,
  .profit-summary,
  .customer-row,
  .submission-card {
    grid-template-columns: 1fr;
  }
}
