*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bys-red: #b71c1c;
  --bys-red-dark: #8b0000;
  --bys-red-light: #c62828;
  --bys-gold: #d4af37;
  --bys-gold-light: #e8c872;
  --bys-gold-dark: #b8960c;
  --bys-brown: #211a17;
  --bys-brown-soft: #4a3f35;
  --bys-cream: #fdf5e6;
  --bys-cream-dark: #f2e7d5;
  --bys-border: rgba(212, 175, 55, 0.4);
  --bys-shadow: rgba(33, 26, 23, 0.08);
}

html {
  overflow-x: hidden;
}

body.agent-page {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', sans-serif;
  color: var(--bys-brown);
  background: var(--bys-cream);
  line-height: 1.6;
  overflow-x: hidden;
  width: 100%;
  max-width: 100%;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--bys-red);
  text-decoration: none;
  word-break: break-word;
}

a:hover {
  color: var(--bys-gold-dark);
}

.agent-wrap {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
  overflow-x: hidden;
}

.agent-hero {
  background: linear-gradient(145deg, var(--bys-red-dark) 0%, var(--bys-red) 45%, var(--bys-red-light) 100%);
  color: #fff;
  border-radius: 16px;
  padding: 32px 24px;
  text-align: center;
  margin-bottom: 20px;
  border: 2px solid var(--bys-gold);
  box-shadow: 0 8px 24px var(--bys-shadow), inset 0 1px 0 rgba(232, 200, 114, 0.25);
  position: relative;
  overflow: hidden;
}

.agent-hero::before {
  content: '';
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: 12px;
  pointer-events: none;
}

.agent-hero h1 {
  font-size: clamp(22px, 5vw, 32px);
  margin-bottom: 8px;
  word-break: break-word;
  color: var(--bys-gold-light);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  position: relative;
}

.agent-hero p {
  font-size: clamp(14px, 3.5vw, 18px);
  opacity: 0.95;
  color: #fff;
  letter-spacing: 0.08em;
  position: relative;
}

.agent-main {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-start;
}

.agent-benefits,
.agent-form-card,
.agent-levels,
.agent-tips {
  background: #fff;
  border: 1px solid var(--bys-border);
  border-radius: 12px;
  padding: 20px;
  width: 100%;
  box-shadow: 0 4px 16px var(--bys-shadow);
}

.agent-benefits {
  flex: 1 1 300px;
  min-width: 0;
  border-top: 3px solid var(--bys-gold);
}

.agent-form-card {
  flex: 1.4 1 360px;
  min-width: 0;
  border-top: 3px solid var(--bys-red);
}

.agent-section-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--bys-brown);
  margin-bottom: 16px;
}

.agent-benefits .agent-section-title {
  color: var(--bys-red);
}

.agent-form-card .agent-section-title {
  color: var(--bys-red);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--bys-border);
}

.benefit-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.benefit-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--bys-brown-soft);
  font-size: 15px;
  word-break: break-word;
}

.benefit-list li::before {
  content: '✓';
  color: var(--bys-gold);
  font-weight: 700;
  flex-shrink: 0;
}

.form-group {
  margin-bottom: 14px;
  width: 100%;
}

.form-group label {
  display: block;
  font-size: 14px;
  color: var(--bys-brown-soft);
  margin-bottom: 6px;
}

.form-group label .req {
  color: var(--bys-red);
}

.form-group input,
.form-group select {
  width: 100%;
  max-width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--bys-border);
  border-radius: 8px;
  font-size: 16px;
  background: #fff;
  color: var(--bys-brown);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--bys-gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.18);
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.form-row .form-group {
  flex: 1 1 140px;
  min-width: 0;
}

.input-with-picker {
  display: flex;
  align-items: stretch;
  width: 100%;
  border: 1px solid var(--bys-border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-with-picker:focus-within {
  border-color: var(--bys-gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.18);
}

.input-with-picker input {
  flex: 1;
  min-width: 0;
  border: none;
  border-radius: 0;
  padding: 10px 12px;
  font-size: 16px;
  background: transparent;
  color: var(--bys-brown);
  outline: none;
}

.input-picker-btn {
  flex-shrink: 0;
  border: none;
  border-left: 1px solid var(--bys-border);
  background: var(--bys-cream-dark);
  padding: 0 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--bys-red);
  cursor: pointer;
  white-space: nowrap;
}

.input-picker-btn:hover {
  background: rgba(212, 175, 55, 0.15);
  color: var(--bys-red-dark);
}

.input-picker-btn:active {
  background: rgba(183, 28, 28, 0.08);
}

.region-picker-root {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: none;
}

.region-picker-root.show {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
}

.region-picker-mask {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: rgba(0, 0, 0, 0.45);
}

.region-picker-panel {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 480px;
  background: #fff;
  border-radius: 12px;
  max-height: min(72vh, 480px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}

.region-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.region-picker-title {
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
}

.region-picker-btn {
  border: none;
  background: none;
  font-size: 15px;
  padding: 4px 8px;
  cursor: pointer;
}

.region-picker-cancel {
  color: #6b7280;
}

.region-picker-confirm {
  color: var(--bys-red);
  font-weight: 600;
}

.region-picker-columns {
  display: flex;
  flex: 1;
  min-height: 200px;
  max-height: calc(72vh - 52px);
  overflow: hidden;
}

.region-picker-col {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-right: 1px solid #f3f4f6;
}

.region-picker-col:last-child {
  border-right: none;
}

.region-picker-col ul {
  list-style: none;
  margin: 0;
  padding: 8px 0;
}

.region-picker-col li {
  padding: 10px 12px;
  font-size: 15px;
  color: #374151;
  cursor: pointer;
  word-break: break-word;
}

.region-picker-col li.active {
  color: var(--bys-red);
  font-weight: 600;
  background: rgba(212, 175, 55, 0.12);
}

@media (min-width: 1024px) and (hover: hover) and (pointer: fine) {
  .region-picker-panel {
    max-width: 520px;
    max-height: 420px;
  }

  .region-picker-columns {
    max-height: 360px;
  }
}

.referrer-hint {
  margin-top: 6px;
  font-size: 13px;
  color: var(--bys-red);
  word-break: break-word;
}

.referrer-hint.error {
  color: var(--bys-red-dark);
}

.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
  margin: 16px 0;
  font-size: 14px;
  color: var(--bys-brown-soft);
}

.checkbox-row input {
  width: auto;
  margin-top: 3px;
  flex-shrink: 0;
  accent-color: var(--bys-red);
}

.btn-submit {
  width: 100%;
  max-width: 100%;
  padding: 14px;
  border: 2px solid var(--bys-gold);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--bys-red-light) 0%, var(--bys-red) 50%, var(--bys-red-dark) 100%);
  color: var(--bys-gold-light);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s, filter 0.2s;
  letter-spacing: 0.06em;
  box-shadow: 0 4px 12px rgba(183, 28, 28, 0.25);
}

.btn-submit:hover:not(:disabled) {
  filter: brightness(1.05);
  box-shadow: 0 6px 16px rgba(183, 28, 28, 0.32);
}

.btn-submit:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.level-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.level-table th,
.level-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--bys-border);
  text-align: left;
  word-break: break-word;
}

.level-table th {
  color: var(--bys-brown-soft);
  font-weight: 500;
}

.agent-levels {
  border-top: 3px solid var(--bys-gold);
}

.agent-levels .agent-section-title {
  color: var(--bys-red);
}

.agent-tips {
  margin-top: 20px;
}

.agent-tips ul {
  padding-left: 18px;
  color: #6b7280;
  font-size: 14px;
}

.agent-tips li {
  margin-bottom: 6px;
  word-break: break-word;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: rgba(31, 41, 55, 0.92);
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 999;
  max-width: calc(100% - 32px);
  word-break: break-word;
  display: none;
}

.toast.show {
  display: block;
}

.back-link {
  position: relative;
  z-index: 20;
  display: inline-block;
  margin-bottom: 12px;
  padding: 8px 0;
  font-size: 14px;
  color: var(--bys-red);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.back-link:hover {
  color: var(--bys-gold-dark);
}

@media (min-width: 768px) {
  .agent-wrap {
    padding: 24px;
  }

  .agent-hero {
    padding: 40px 32px;
  }
}

/* 代理 UI 背景（仅手机端，与 agent-portal 共用脚本） */
@media (max-width: 768px) {
  html.ap-has-ui-bg,
  body.agent-page.ap-has-ui-bg {
    background: transparent !important;
  }

  .ap-ui-bg-stack {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
  }

  .ap-ui-bg-layer {
    position: absolute;
    inset: 0;
    overflow: hidden;
  }

  .ap-ui-bg-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    transform-origin: center center;
    display: block;
    pointer-events: none;
    user-select: none;
  }

  body.agent-page.ap-has-ui-bg > *:not(.ap-ui-bg-stack):not(.region-picker-root):not(.agent-captcha-overlay):not(.toast) {
    position: relative;
    z-index: 1;
  }

  body.agent-page.ap-has-ui-bg > .region-picker-root,
  body.agent-page.ap-has-ui-bg > .agent-captcha-overlay {
    position: fixed !important;
    inset: 0 !important;
    z-index: 10060 !important;
  }
}

.agent-captcha-overlay {
  position: fixed;
  inset: 0;
  z-index: 10060;
  display: none;
  padding: 0;
  background: rgba(0, 0, 0, 0.45);
}

.agent-captcha-overlay.show {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
}

.agent-captcha-panel {
  position: relative;
  width: 100%;
  max-width: 360px;
  background: #fff;
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  max-height: calc(100vh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 1024px) and (hover: hover) and (pointer: fine) {
  .agent-captcha-panel {
    max-width: 360px;
  }
}

.agent-captcha-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

.agent-captcha-close {
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: #909399;
}

.agent-captcha-tip {
  font-size: 13px;
  color: #909399;
  margin-bottom: 10px;
}

.agent-captcha-stage {
  position: relative;
  width: 320px;
  max-width: 100%;
  height: 160px;
  margin: 0 auto;
  border-radius: 8px;
  overflow: hidden;
  background: #f5f7fa;
}

.agent-captcha-bg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.agent-captcha-piece {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  z-index: 2;
}

.agent-captcha-slider-wrap {
  margin-top: 12px;
}

.agent-captcha-slider-track {
  position: relative;
  height: 40px;
  border-radius: 20px;
  background: #f2f3f5;
  border: 1px solid #e4e7ed;
}

.agent-captcha-slider-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  border-radius: 20px;
  background: rgba(183, 28, 28, 0.12);
}

.agent-captcha-slider-btn {
  position: absolute;
  left: 0;
  top: 2px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bys-red);
  color: var(--bys-gold-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: grab;
  user-select: none;
  touch-action: none;
  border: 1px solid var(--bys-gold);
}

.agent-captcha-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.agent-captcha-refresh,
.agent-captcha-confirm {
  flex: 1;
  border: none;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  cursor: pointer;
}

.agent-captcha-refresh {
  background: #f2f3f5;
  color: #606266;
}

.agent-captcha-confirm {
  background: var(--bys-red);
  color: var(--bys-gold-light);
  border: 1px solid var(--bys-gold);
}

.agent-captcha-confirm:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.agent-captcha-error {
  margin-top: 8px;
  font-size: 12px;
  color: #f56c6c;
  min-height: 18px;
}
