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

:root {
  --primary: #ff7043;
  --primary-press: #f4511e;
  --success: #43a047;
  --danger: #e53935;
  --bg: #f7f6f3;
  --text: #333;
  --text-light: #888;
  --line: #ebe8e3;
  --input-bg: #fff;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue',
    sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.page {
  max-width: 400px;
  margin: 0 auto;
  padding: 20px 18px 28px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* 顶部标题区 */
.header {
  padding: 8px 0 24px;
}

.header h1 {
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
}

.header p {
  font-size: 0.8125rem;
  color: var(--text-light);
  margin-top: 6px;
}

/* 主内容区 - 无卡片阴影，扁平 */
.main {
  flex: 1;
}

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

.form-group input {
  width: 100%;
  height: 50px;
  padding: 0 16px;
  font-size: 1rem;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: var(--input-bg);
  color: var(--text);
  outline: none;
  -webkit-appearance: none;
}

.form-group input:focus {
  border-bottom-color: var(--primary);
}

.form-group input::placeholder {
  color: #bbb;
}

.btn {
  display: block;
  width: 100%;
  height: 48px;
  margin-top: 24px;
  font-size: 1rem;
  font-weight: 500;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: 24px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn:active {
  background: var(--primary-press);
}

.btn:disabled {
  opacity: 0.55;
}

.btn-text {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 10px;
  font-size: 0.875rem;
  color: var(--text-light);
  background: none;
  border: none;
  cursor: pointer;
  text-align: center;
}

/* 推广人提示 */
.referrer-tip {
  padding: 12px 0 4px;
  font-size: 0.875rem;
  color: var(--text-light);
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}

.referrer-tip em {
  font-style: normal;
  color: var(--text);
  font-weight: 500;
}

/* 结果页 */
.result-panel {
  display: none;
}

.result-panel.show {
  display: block;
}

.result-msg {
  font-size: 1rem;
  color: var(--success);
  margin-bottom: 16px;
}

.result-sub {
  font-size: 0.8125rem;
  color: var(--text-light);
  margin-bottom: 12px;
}

.link-box {
  padding: 14px 0;
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.7;
  word-break: break-all;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}

/* 推广列表 */
.list-summary {
  font-size: 0.875rem;
  color: var(--text-light);
  padding-bottom: 12px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.list-summary b {
  color: var(--primary);
  font-weight: 600;
}

.referral-list {
  list-style: none;
}

.referral-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.9375rem;
}

.referral-item .row-name {
  font-weight: 500;
  margin-bottom: 4px;
}

.referral-item .row-phone {
  color: var(--text-light);
  font-size: 0.8125rem;
}

.referral-item .row-time {
  color: #bbb;
  font-size: 0.75rem;
  margin-top: 4px;
}

.empty-state {
  text-align: center;
  padding: 36px 0;
  color: var(--text-light);
  font-size: 0.875rem;
}

/* 底部导航 */
.footer-nav {
  margin-top: auto;
  padding-top: 32px;
  text-align: center;
}

.footer-nav a {
  font-size: 0.8125rem;
  color: var(--text-light);
  text-decoration: none;
}

.footer-nav a + a::before {
  content: '·';
  margin: 0 8px;
  color: #ccc;
}

/* 错误/空状态 */
.state-box {
  text-align: center;
  padding: 40px 0;
  color: var(--text-light);
  font-size: 0.875rem;
}

.state-box a {
  display: inline-block;
  margin-top: 16px;
  color: var(--primary);
  text-decoration: none;
  font-size: 0.875rem;
}

.hidden {
  display: none !important;
}

.loading {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 6px;
  vertical-align: -2px;
}

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

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(120%);
  max-width: calc(100vw - 36px);
  padding: 10px 18px;
  background: rgba(51, 51, 51, 0.88);
  color: #fff;
  border-radius: 20px;
  font-size: 0.8125rem;
  z-index: 1000;
  transition: transform 0.25s ease;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  background: rgba(229, 57, 53, 0.92);
}
