/* AI旺财 v2 Design System - AI Business Growth Factory
   Style: Modern SaaS (Linear/Vercel/Stripe inspired). Light theme. */

:root {
  --bg: #fafafa;
  --bg-card: #ffffff;
  --bg-sidebar: #0f172a;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --text: #1f2937;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --primary: #1a56db;
  --primary-hover: #1e40af;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.1);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: var(--font); color: var(--text); line-height: 1.6; background: var(--bg); }
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: .9rem; }
.muted { color: var(--text-secondary); font-size: .85rem; }

/* ============ Buttons ============ */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 20px; border-radius: var(--radius-sm); font-weight: 600; font-size: .9rem; border: none; transition: all .15s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 7px 14px; font-size: .82rem; }
.btn-lg { padding: 14px 32px; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ============ Admin Shell ============ */
.admin-body { background: var(--bg); }
.admin-shell { display: flex; min-height: 100vh; }

.sidebar { width: 230px; background: var(--bg-sidebar); color: #cbd5e1; display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; z-index: 50; }
.side-brand { padding: 20px; font-size: 1.3rem; font-weight: 800; color: #fff; display: flex; align-items: baseline; gap: 8px; }
.side-brand-sub { font-size: .75rem; font-weight: 400; color: #64748b; }
.side-nav { flex: 1; padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; }
.side-link { padding: 10px 14px; border-radius: 8px; font-size: .88rem; color: #94a3b8; transition: all .15s; }
.side-link:hover { color: #fff; background: rgba(255,255,255,.06); }
.side-link.active { color: #fff; background: var(--primary); }
.side-foot { padding: 16px; border-top: 1px solid rgba(255,255,255,.08); }
.side-external { font-size: .8rem; color: #64748b; }
.side-external:hover { color: #fff; }

.admin-main { flex: 1; margin-left: 230px; padding: 32px; max-width: calc(100% - 230px); }

/* ============ Page Header ============ */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 28px; gap: 16px; flex-wrap: wrap; }
.page-header h1 { font-size: 1.6rem; font-weight: 800; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ============ Cards ============ */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; transition: box-shadow .15s; display: block; }
.card:hover { box-shadow: var(--shadow-lg); }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.card-title { font-size: 1.05rem; font-weight: 700; }
.card-sub { font-size: .82rem; color: var(--text-secondary); }
.card-desc { font-size: .85rem; color: var(--text-secondary); margin-top: 10px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.biz-card .biz-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: .8rem; color: var(--text-secondary); }
.demo-tag { font-size: .68rem; background: #f59e0b15; color: #b45309; padding: 2px 8px; border-radius: 4px; vertical-align: middle; font-weight: 600; }

/* ============ Badges ============ */
.score-badge { display: inline-flex; align-items: center; padding: 4px 12px; border-radius: 6px; font-weight: 700; font-size: .82rem; white-space: nowrap; }
.status-badge { display: inline-flex; padding: 3px 10px; border-radius: 5px; font-weight: 600; font-size: .75rem; white-space: nowrap; }

/* ============ Grid ============ */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

/* ============ Stats (Dashboard) ============ */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-bottom: 28px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat-label { font-size: .78rem; color: var(--text-secondary); margin-bottom: 6px; }
.stat-value { font-size: 1.7rem; font-weight: 800; }
.stat-value.green { color: var(--success); }
.stat-value.red { color: var(--danger); }
.stat-value.blue { color: var(--primary); }

/* ============ Funnel ============ */
.funnel { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 24px; }
.funnel-title { font-size: 1rem; font-weight: 700; margin-bottom: 16px; }
.funnel-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.funnel-label { width: 90px; font-size: .82rem; color: var(--text-secondary); text-align: right; flex-shrink: 0; }
.funnel-bar-wrap { flex: 1; background: var(--border-light); border-radius: 6px; height: 30px; position: relative; overflow: hidden; }
.funnel-bar { height: 100%; background: linear-gradient(90deg, var(--primary), #3b82f6); border-radius: 6px; display: flex; align-items: center; padding: 0 10px; color: #fff; font-size: .78rem; font-weight: 700; min-width: 36px; transition: width .4s; }
.funnel-rate { width: 60px; font-size: .78rem; color: var(--text-muted); flex-shrink: 0; }

/* ============ Tasks (Dashboard) ============ */
.task-list { display: flex; flex-direction: column; gap: 12px; }
.task-item { display: flex; align-items: center; justify-content: space-between; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 18px; gap: 12px; flex-wrap: wrap; }
.task-info { flex: 1; min-width: 200px; }
.task-name { font-weight: 700; font-size: .92rem; }
.task-meta { font-size: .78rem; color: var(--text-secondary); }
.task-action { background: var(--primary-light); color: var(--primary); padding: 6px 14px; border-radius: 6px; font-size: .8rem; font-weight: 600; white-space: nowrap; }

/* ============ Tables ============ */
.table-wrap { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .87rem; }
th { text-align: left; padding: 12px 16px; background: var(--border-light); font-weight: 700; font-size: .78rem; color: var(--text-secondary); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfc; }

/* ============ Forms ============ */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-input, .form-select, .form-textarea { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; font-size: .9rem; color: var(--text); transition: border-color .15s; }
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,219,.1); }
.form-textarea { min-height: 100px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-hint { font-size: .75rem; color: var(--text-muted); margin-top: 4px; }

/* ============ Modal ============ */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 200; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-backdrop.show { display: flex; }
.modal { background: #fff; border-radius: 16px; padding: 28px; max-width: 560px; width: 100%; max-height: 90vh; overflow-y: auto; position: relative; }
.modal h3 { margin-bottom: 8px; font-size: 1.15rem; }
.modal .close { position: absolute; top: 16px; right: 16px; background: none; border: none; font-size: 1.4rem; color: var(--text-muted); }

/* ============ Tabs ============ */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border-light); margin-bottom: 24px; overflow-x: auto; }
.tab { padding: 10px 20px; font-size: .88rem; font-weight: 600; color: var(--text-secondary); border-bottom: 2px solid transparent; margin-bottom: -2px; white-space: nowrap; background: none; border-top: none; border-left: none; border-right: none; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab:hover { color: var(--primary); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ============ AI Panel ============ */
.ai-panel { background: linear-gradient(135deg, #eff6ff, #fafafa); border: 1px solid #bfdbfe; border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.ai-panel h4 { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.ai-loading { display: flex; align-items: center; gap: 10px; color: var(--text-secondary); padding: 20px 0; }
.spinner { width: 20px; height: 20px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ai-not-configured { background: #fffbeb; border: 1px solid #fcd34d; border-radius: var(--radius-sm); padding: 14px; font-size: .85rem; color: #92400e; margin-bottom: 16px; }

/* ============ Score Breakdown ============ */
.score-breakdown { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.score-header { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.score-big { font-size: 2.8rem; font-weight: 900; line-height: 1; }
.score-factor { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: .82rem; }
.score-factor-label { width: 100px; color: var(--text-secondary); flex-shrink: 0; }
.score-factor-bar { flex: 1; background: var(--border-light); height: 8px; border-radius: 4px; overflow: hidden; }
.score-factor-fill { height: 100%; border-radius: 4px; background: var(--primary); }
.score-factor-val { width: 60px; text-align: right; color: var(--text-secondary); flex-shrink: 0; }
.score-explain { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border-light); }
.score-explain h5 { font-size: .85rem; margin-bottom: 8px; }
.score-explain ul { padding-left: 18px; font-size: .82rem; color: var(--text-secondary); }
.score-explain li { margin-bottom: 4px; }

/* ============ Sales Script ============ */
.script-block { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; margin-bottom: 14px; }
.script-block h5 { font-size: .82rem; color: var(--text-secondary); margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.script-text { font-size: .87rem; white-space: pre-wrap; }
.copy-btn { background: var(--primary-light); color: var(--primary); border: none; padding: 4px 12px; border-radius: 5px; font-size: .75rem; font-weight: 600; }

/* ============ Empty State ============ */
.empty-state { text-align: center; padding: 60px 20px; background: var(--bg-card); border: 1px dashed var(--border); border-radius: var(--radius); }
.empty-state h3 { margin-bottom: 8px; }
.empty-state .btn { margin-top: 16px; }

/* ============ Toast ============ */
.toast { position: fixed; bottom: 24px; right: 24px; background: #0f172a; color: #fff; padding: 12px 20px; border-radius: 10px; font-size: .88rem; z-index: 300; display: none; box-shadow: var(--shadow-lg); }
.toast.show { display: block; animation: slideIn .3s; }
@keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ============ Landing Page ============ */
.landing-body { background: #fff; }
.landing-nav { position: sticky; top: 0; z-index: 100; background: rgba(255,255,255,.9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.landing-nav-inner { max-width: 1100px; margin: 0 auto; padding: 16px 24px; display: flex; align-items: center; justify-content: space-between; }
.landing-brand { font-size: 1.3rem; font-weight: 900; color: #0f172a; display: flex; align-items: baseline; gap: 8px; }
.landing-brand-cn { font-size: .78rem; font-weight: 500; color: var(--text-muted); }
.landing-links { display: flex; gap: 24px; font-size: .9rem; color: var(--text-secondary); }
.landing-links a:hover { color: var(--primary); }

.landing-hero { max-width: 1100px; margin: 0 auto; padding: 100px 24px 80px; text-align: center; }
.landing-hero h1 { font-size: clamp(2.5rem, 7vw, 4.5rem); font-weight: 900; line-height: 1.1; margin-bottom: 8px; letter-spacing: -0.02em; }
.landing-hero .hero-tagline { font-size: clamp(1rem, 3vw, 1.4rem); color: var(--primary); font-weight: 700; margin-bottom: 20px; }
.landing-hero .hero-desc { max-width: 640px; margin: 0 auto 36px; color: var(--text-secondary); font-size: 1.05rem; line-height: 1.7; }
.landing-hero-ctas { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

.landing-section { max-width: 1100px; margin: 0 auto; padding: 70px 24px; }
.landing-section h2 { font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 800; text-align: center; margin-bottom: 12px; }
.landing-section .section-desc { text-align: center; color: var(--text-secondary); margin-bottom: 48px; }

.steps-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 20px; }
.step-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; padding: 28px 22px; text-align: center; }
.step-num { display: inline-flex; width: 40px; height: 40px; background: var(--primary); color: #fff; border-radius: 50%; align-items: center; justify-content: center; font-weight: 800; margin-bottom: 14px; }
.step-card h3 { font-size: 1.05rem; margin-bottom: 8px; }
.step-card p { font-size: .85rem; color: var(--text-secondary); }

.pricing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }
.price-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; padding: 28px; text-align: center; position: relative; }
.price-card.featured { border: 2px solid var(--primary); box-shadow: var(--shadow-lg); }
.price-badge { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: var(--primary); color: #fff; padding: 4px 14px; border-radius: 999px; font-size: .72rem; font-weight: 700; }
.price-name { font-size: 1rem; font-weight: 700; margin-bottom: 8px; }
.price-amount { font-size: 2.2rem; font-weight: 900; margin-bottom: 16px; }
.price-features { list-style: none; text-align: left; margin-bottom: 20px; }
.price-features li { font-size: .85rem; padding: 6px 0; border-bottom: 1px solid var(--border-light); }
.price-features li:last-child { border: none; }
.price-features li::before { content: "✓ "; color: var(--success); font-weight: 700; }

.landing-footer { background: #0f172a; color: #94a3b8; padding: 48px 24px 32px; margin-top: 60px; }
.landing-footer-inner { max-width: 1100px; margin: 0 auto; display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 32px; padding-bottom: 32px; border-bottom: 1px solid #1e293b; }
.landing-footer h4 { color: #fff; font-size: .85rem; margin-bottom: 12px; }
.landing-footer a { display: block; font-size: .82rem; padding: 3px 0; color: #94a3b8; }
.landing-footer a:hover { color: #fff; }
.landing-footer .landing-brand { color: #fff; margin-bottom: 8px; }
.landing-footer-bottom { max-width: 1100px; margin: 24px auto 0; font-size: .78rem; text-align: center; }

/* ============ Responsive ============ */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .admin-main { margin-left: 0; max-width: 100%; padding: 20px 16px; }
  .form-row { grid-template-columns: 1fr; }
  .landing-links { display: none; }
  .landing-footer-inner { grid-template-columns: 1fr; }
  .landing-hero { padding: 60px 20px 50px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .funnel-label { width: 70px; font-size: .75rem; }
}

/* Mobile admin nav fallback */
.mobile-admin-nav { display: none; }
@media (max-width: 768px) {
  .mobile-admin-nav { display: flex; overflow-x: auto; gap: 8px; padding: 12px 16px; background: var(--bg-sidebar); position: sticky; top: 0; z-index: 50; }
  .mobile-admin-nav a { color: #94a3b8; font-size: .8rem; padding: 6px 12px; border-radius: 6px; white-space: nowrap; }
  .mobile-admin-nav a.active { background: var(--primary); color: #fff; }
}
