/* ===== CSS Tokens ===== */
:root {
  --bg:        #FAFBFE;
  --surface:   #FFFFFF;
  --border:    #E8ECF4;
  --text-1:    #0F172A;
  --text-2:    #64748B;
  --text-3:    #94A3B8;
  --accent:    #1649D4;
  --accent-h:  #1240C0;
  --accent-bg: #EEF3FF;
  --green:     #16A34A;
  --green-bg:  #F0FDF4;
  --red:       #EF4444;
  --red-bg:    #FEF2F2;
  --radius-card: 14px;
  --radius-btn:  8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'PingFang SC', system-ui, -apple-system, sans-serif;
       font-size: 15px; line-height: 1.6; color: var(--text-1);
       background: var(--bg); min-width: 1024px; }

/* ===== Nav ===== */
.nav {
  height: 58px; background: rgba(255,255,255,0.92); border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; padding: 0 36px; gap: 28px;
}
.nav-logo { font-size: 18px; font-weight: 800; letter-spacing: -0.03em; color: var(--text-1); text-decoration: none; display: flex; align-items: center; gap: 8px; }
.nav-logo .badge { background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 4px; }
.nav-links { display: flex; gap: 4px; }
.nav-link { padding: 6px 14px; border-radius: 6px; color: var(--text-2); text-decoration: none; font-size: 14px; font-weight: 500; }
.nav-link:hover { background: var(--bg); color: var(--text-1); }
.nav-link.active { color: var(--accent); background: var(--accent-bg); }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.nav-quota { font-size: 13px; color: var(--text-2); background: var(--bg); border: 1px solid var(--border); padding: 4px 12px; border-radius: 20px; cursor: pointer; }
.nav-quota.vip { color: var(--green); background: var(--green-bg); border-color: #86EFAC; }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
       height: 44px; padding: 0 20px; border-radius: var(--radius-btn);
       font-size: 15px; font-weight: 500; cursor: pointer; border: none;
       transition: all 0.15s ease; text-decoration: none; }
.btn-primary { background: var(--green); color: #fff; width: 100%; }
.btn-primary:hover { background: #15803D; }
.btn-primary:disabled { background: var(--text-3); cursor: not-allowed; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-h); }
.btn-ghost { background: transparent; color: var(--text-1); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-nav-login { background: #1E293B; color: #fff; height: 36px; padding: 0 18px; font-size: 14px; box-shadow: 0 1px 2px rgba(15,23,42,.1), 0 2px 6px rgba(15,23,42,.08); }
.btn-nav-login:hover { background: #0F172A; }
.btn-danger { background: transparent; color: var(--red); border: none; font-size: 14px; cursor: pointer; }

/* ===== Card ===== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 24px; }
.card-hover { cursor: pointer; transition: all 0.2s ease; }
.card-hover:hover { box-shadow: 0 4px 20px rgba(79,70,229,0.1); border-color: #A5B4FC; transform: translateY(-2px); }

/* ===== Form ===== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 14px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
.form-label .required { color: var(--red); margin-left: 2px; }
.form-input, .form-textarea, .form-select {
  width: 100%; height: 44px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius-btn);
  font-size: 14px; color: var(--text-1); background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s; outline: none;
  font-family: inherit;
}
.form-textarea { height: auto; min-height: 100px; padding: 10px 12px; resize: vertical; }
.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}
.form-error { font-size: 12px; color: var(--red); margin-top: 4px; }

/* ===== Toast ===== */
.toast-container { position: fixed; top: 80px; right: 24px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text-1); color: #fff; padding: 12px 20px; border-radius: 10px; font-size: 14px;
         animation: slideIn 0.25s ease; max-width: 320px; }
.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== Modal ===== */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 500; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal-card { background: var(--surface); border-radius: var(--radius-card); padding: 32px; width: 400px; position: relative; }
.modal-title { font-size: 20px; font-weight: 700; margin-bottom: 24px; }
.modal-close { position: absolute; top: 16px; right: 16px; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-3); }

/* ===== Layout ===== */
.page { max-width: 1120px; margin: 0 auto; padding: 32px 24px; }
.page-narrow { max-width: 720px; margin: 0 auto; padding: 32px 24px; }

/* ===== Loading spinner ===== */
.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Profile banner ===== */
.profile-banner { display: none; background: var(--accent-bg); border: 1px solid #C7D2FE; border-radius: var(--radius-card); padding: 14px 20px; margin-bottom: 24px; font-size: 14px; color: var(--accent); align-items: center; gap: 8px; }
.profile-banner.show { display: flex; }
.profile-banner a { color: var(--accent); font-weight: 600; margin-left: 4px; }
.banner-cta-btn {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--accent); color: #fff !important;
  font-size: 13px; font-weight: 600;
  padding: 7px 14px; border-radius: 8px;
  white-space: nowrap; text-decoration: none !important;
  flex-shrink: 0;
}
.banner-cta-btn::after {
  content: ''; display: inline-block;
  width: 6px; height: 6px;
  border-top: 2px solid #fff; border-right: 2px solid #fff;
  transform: rotate(45deg) translateY(1px);
}

/* ===== Breadcrumb ===== */
.breadcrumb { font-size: 13px; color: var(--text-3); margin-bottom: 20px; }
.breadcrumb a { color: var(--text-3); text-decoration: none; }
.breadcrumb a:hover { color: var(--text-2); }

/* ===== Email result card ===== */
.email-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); overflow: hidden; margin-bottom: 20px; }
.email-card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.email-card-label { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.email-card-label .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; }
.email-card-label .dot.green { background: var(--green); }
.email-subject { padding: 14px 20px; background: #FEFCE8; border-bottom: 1px solid var(--border); border-left: 3px solid #EAB308; font-family: 'PingFang SC', system-ui, -apple-system, sans-serif; font-size: 14px; }
.email-subject-label { font-size: 11px; color: #92400E; font-weight: 600; letter-spacing: 0.05em; margin-bottom: 4px; }
.email-body { padding: 20px; font-family: 'PingFang SC', system-ui, -apple-system, sans-serif; font-size: 14px; line-height: 1.85; white-space: pre-wrap; word-break: break-word; }

/* ===== History item ===== */
.history-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 16px 20px; margin-bottom: 12px; cursor: pointer; transition: border-color 0.15s; }
.history-item:hover { border-color: #A5B4FC; }
.history-item-head { display: flex; align-items: center; justify-content: space-between; }
.history-scene { font-size: 13px; color: var(--accent); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.history-date { font-size: 12px; color: var(--text-3); }
.history-company { font-weight: 600; margin: 4px 0 2px; }
.history-subject { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 600px; }
.history-detail { display: none; margin-top: 16px; border-top: 1px solid var(--border); padding-top: 16px; }
.history-item.expanded .history-detail { display: block; }

/* ===== Empty state ===== */
.empty-state { text-align: center; padding: 80px 20px; color: var(--text-3); }
.empty-state-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state-title { font-size: 18px; font-weight: 600; color: var(--text-2); margin-bottom: 8px; }
.empty-state-desc { font-size: 14px; margin-bottom: 24px; }

/* ===== Scene grid ===== */
.scene-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.scene-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 20px 20px 18px; cursor: pointer; transition: border-color 0.14s, box-shadow 0.14s; display: flex; flex-direction: column; }
.scene-card:hover { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,70,229,0.06); transform: none; }
.scene-card.custom { border-style: dashed; background: var(--bg); }
.scene-num { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; color: var(--text-3); margin-bottom: 10px; font-variant-numeric: tabular-nums; }
.scene-name { font-weight: 600; font-size: 15px; margin-bottom: 3px; letter-spacing: -0.02em; }
.scene-name-en { font-size: 10.5px; color: var(--text-3); font-weight: 500; margin-bottom: 9px; letter-spacing: 0.02em; }
.scene-desc { font-size: 12.5px; color: var(--text-2); line-height: 1.55; }

/* ===== SMS countdown ===== */
.btn-sms { height: 44px; padding: 0 16px; border: 1px solid var(--border); border-radius: var(--radius-btn); background: var(--surface); color: var(--accent); font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap; flex-shrink: 0; }
.btn-sms:disabled { color: var(--text-3); cursor: not-allowed; }
.phone-row { display: flex; gap: 8px; }
.phone-row .form-input { flex: 1; }

/* ===== User dropdown ===== */
.user-menu { position: relative; }
.user-btn { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); font-size: 14px; color: var(--text-1); }
.user-btn:hover { background: var(--bg); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.user-dropdown { display: none; position: absolute; top: calc(100% + 8px); right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 6px; min-width: 140px; box-shadow: 0 8px 24px rgba(0,0,0,0.1); z-index: 200; }
.user-menu.open .user-dropdown { display: block; }
.dropdown-item { display: block; padding: 8px 12px; border-radius: 6px; font-size: 14px; color: var(--text-1); text-decoration: none; cursor: pointer; }
.dropdown-item:hover { background: var(--bg); }
.dropdown-item.danger { color: var(--red); }

/* ===== Footer ===== */
.site-footer { border-top: 1px solid var(--border); margin-top: 48px; padding: 24px; text-align: center; }
.site-footer-contact { font-size: 13px; color: var(--text-3); }
.site-footer-contact a { color: var(--accent); text-decoration: none; font-weight: 500; }
.site-footer-contact a:hover { text-decoration: underline; }
.site-footer-copy { font-size: 12px; color: var(--text-3); margin-top: 5px; opacity: 0.7; }

/* ===== Collapsed company fields ===== */
.company-fields-section { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-btn); margin-bottom: 16px; overflow: hidden; }
.company-fields-toggle { padding: 12px 16px; font-size: 14px; font-weight: 500; color: var(--text-2); cursor: pointer; display: flex; align-items: center; justify-content: space-between; }
.company-fields-body { padding: 0 16px 16px; display: none; }
.company-fields-section.open .company-fields-body { display: block; }
