@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg: #f5f3ef;
  --card: #ffffff;
  --border: #e8e5df;
  --text: #1a1a2e;
  --text2: #6b7280;
  --text3: #9ca3af;
  --accent: #6366f1;
  --accent2: #8b5cf6;
  --red: #ef4444;
  --blue: #3b82f6;
  --green: #22c55e;
  --orange: #f59e0b;
  --gold: #d97706;
  --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.06);
  --radius: 16px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.header {
  padding: 24px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1400px;
  margin: 0 auto;
}
.header h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.header h1 span { color: var(--accent); }
.header-right {
  display: flex;
  gap: 8px;
  align-items: center;
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
  margin-right: 6px;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.status-text { font-size: 13px; color: var(--text2); }

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  padding: 0 32px;
  max-width: 1400px;
  margin: 0 auto 16px;
}
.tab-btn {
  padding: 10px 28px;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--text2);
  cursor: pointer;
  border-radius: 10px 10px 0 0;
  transition: all 0.2s;
  position: relative;
}
.tab-btn:hover { color: var(--text); background: rgba(99,102,241,0.05); }
.tab-btn.active {
  color: var(--accent);
  background: var(--card);
  box-shadow: var(--shadow);
}
.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: 0; left: 20%; right: 20%;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

/* Main */
.main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 32px 40px;
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Bento Grid */
.bento {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 12px;
}

/* Card */
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  transition: box-shadow 0.2s;
}
.card:hover { box-shadow: var(--shadow-lg); }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.card-badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-green { background: #ecfdf5; color: #059669; }
.badge-blue { background: #eff6ff; color: #2563eb; }
.badge-orange { background: #fff7ed; color: #c2410c; }

/* 大号码 */
.big-number {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1;
}

/* Ball */
.ball {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}
.ball-sm { width: 30px; height: 30px; font-size: 11px; }
.ball-red { background: linear-gradient(135deg, #ef4444, #dc2626); }
.ball-blue { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.ball-gold { background: linear-gradient(135deg, #f59e0b, #d97706); }
.ball-row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.ball-sep {
  color: var(--text3);
  font-size: 14px;
  font-weight: 500;
  margin: 0 4px;
}

/* Button */
.btn {
  padding: 8px 20px;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent2); }
.btn-ghost { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover { background: #f9fafb; border-color: #d1d5db; }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-green { background: var(--green); color: white; }
.btn-green:hover { background: #16a34a; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn .spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Table */
.score-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}
.score-table th {
  text-align: left;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
.score-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #f3f4f6;
}
.score-table tr:hover td { background: #fafaf8; }
.score-table .rank-1 td { background: #fef3c7; }
.score-table .rank-2 td { background: #fef9c3; }
.score-table .rank-3 td { background: #fffbeb; }
.score-bar {
  height: 4px;
  border-radius: 2px;
  background: #e5e7eb;
  overflow: hidden;
  min-width: 60px;
}
.score-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.4s ease;
}

/* Recommend */
.rec-group {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.15s;
}
.rec-group:hover { background: #fafaf8; }
.rec-group.fixed {
  background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
  border-color: #86efac;
}
.rec-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  min-width: 56px;
  flex-shrink: 0;
}
.rec-label.fixed-label { color: #16a34a; }

/* Config Row */
.config-row {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.config-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.config-item label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
}
.config-item input, .config-item select {
  width: 70px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  outline: none;
  transition: border-color 0.15s;
}
.config-item input:focus, .config-item select:focus { border-color: var(--accent); }

/* Cost Banner */
.cost-banner {
  padding: 14px 18px;
  background: linear-gradient(135deg, #eef2ff, #e0e7ff);
  border-radius: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.cost-item { text-align: center; }
.cost-label { font-size: 11px; color: var(--text3); font-weight: 500; }
.cost-value { font-size: 20px; font-weight: 700; color: var(--accent); }
.cost-value.total { color: var(--red); font-size: 24px; }

/* Algorithm Detail */
.algo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.algo-chip {
  padding: 8px 10px;
  border-radius: 10px;
  background: #f9fafb;
  border: 1px solid #f3f4f6;
  text-align: center;
}
.algo-chip-name { font-size: 10px; color: var(--text3); font-weight: 500; }
.algo-chip-weight { font-size: 16px; font-weight: 700; color: var(--text); }

/* Loading */
.loading-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(245,243,239,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.loading-overlay.hidden { display: none; }

/* Grid spans */
.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; }
.col-8 { grid-column: span 8; }
.col-12 { grid-column: span 12; }

/* Copy toast */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 12px 24px;
  background: #1a1a2e;
  color: white;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  z-index: 2000;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* Weight Editor */
.weight-editor { display: flex; flex-direction: column; gap: 10px; }
.weight-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: #f9fafb;
  border: 1px solid #f3f4f6;
  transition: background 0.15s;
}
.weight-row:hover { background: #f3f4f6; }
.weight-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  min-width: 90px;
  flex-shrink: 0;
}
.weight-desc {
  font-size: 10px;
  color: var(--text3);
  min-width: 100px;
  flex-shrink: 0;
}
.weight-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: #e5e7eb;
  outline: none;
}
.weight-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.weight-slider::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid white;
}
.weight-val {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  min-width: 36px;
  text-align: right;
}
.weight-pct {
  font-size: 11px;
  color: var(--text3);
  min-width: 40px;
  text-align: right;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }

/* Responsive */
@media (max-width: 1024px) {
  .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-12 { grid-column: span 12; }
  .header { padding: 16px 20px; }
  .main { padding: 0 16px 32px; }
  .tabs { padding: 0 16px; }
  .bento { gap: 10px; }
}
@media (max-width: 640px) {
  .header h1 { font-size: 18px; }
  .cost-banner { flex-direction: column; }
  .config-row { gap: 10px; }
}
