:root {
  --primary: #6C5CE7;
  --primary-light: #A29BFE;
  --primary-dark: #5A4BD1;
  --primary-bg: #F0EDFF;
  --success: #00B894;
  --success-bg: #E6FFF7;
  --danger: #E17055;
  --danger-bg: #FFF3F0;
  --warning: #F59E0B;
  --warning-bg: #FFF8E1;
  --text-primary: #1A1A2E;
  --text-secondary: #636E72;
  --text-light: #B2BEC3;
  --bg: #F5F5FA;
  --bg-white: #FFFFFF;
  --border: #E8E8EE;
  --border-light: #F0F0F5;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.1);
  --radius: 14px;
  --radius-sm: 8px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg); color: var(--text-primary); line-height: 1.6; min-height: 100vh;
}
a { text-decoration: none; color: inherit; }

/* Header */
.header {
  background: linear-gradient(150deg, #1A1A2E 0%, #2D1B69 40%, var(--primary) 100%);
  color: white; padding: 2rem 1.5rem; text-align: center;
}
.header-content { max-width: 800px; margin: 0 auto; }
.back-link { display: inline-block; color: rgba(255,255,255,0.7); font-size: 0.85rem; margin-bottom: 0.75rem; transition: color 0.2s; }
.back-link:hover { color: white; }
.logo { display: flex; align-items: center; justify-content: center; gap: 0.6rem; margin-bottom: 0.4rem; }
.logo-icon { font-size: 1.75rem; }
.logo h1 { font-size: 1.6rem; font-weight: 700; }
.tagline { font-size: 0.92rem; opacity: 0.8; }

/* Stats Bar */
.stats-bar {
  background: var(--bg-white); border-bottom: 1px solid var(--border-light);
  padding: 1rem 1.5rem; position: sticky; top: 0; z-index: 50;
}
.stats-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; gap: 2rem; flex-wrap: wrap;
}
.stat-item { display: flex; flex-direction: column; align-items: center; min-width: 70px; }
.stat-item .stat-num { font-size: 1.5rem; font-weight: 800; color: var(--primary); }
.stat-item .stat-label { font-size: 0.72rem; color: var(--text-light); }
.stat-alert .stat-num { color: var(--danger); }
.stat-down .stat-num { color: var(--success); }
.stat-up .stat-num { color: var(--danger); }
.stat-actions { margin-left: auto; display: flex; gap: 0.5rem; }

/* Buttons */
.btn {
  padding: 0.55rem 1.15rem; border-radius: var(--radius-sm);
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  border: none; font-family: inherit; transition: all 0.2s; display: inline-flex; align-items: center; gap: 0.3rem;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 2px 8px rgba(108,92,231,0.3); }
.btn-outline { background: var(--bg-white); color: var(--text-secondary); border: 1.5px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.78rem; }
.btn-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(225,112,85,0.2); }
.btn-danger:hover { background: var(--danger); color: white; }

/* Empty State */
.empty-state {
  text-align: center; padding: 4rem 1.5rem; color: var(--text-light);
}
.empty-icon { font-size: 4rem; margin-bottom: 1rem; opacity: 0.5; }
.empty-state h3 { font-size: 1.15rem; color: var(--text-secondary); margin-bottom: 0.5rem; }
.empty-state p { font-size: 0.9rem; margin-bottom: 1.5rem; }

/* Products Grid */
.main-content { max-width: 1200px; margin: 1.5rem auto; padding: 0 1.5rem; }
.products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1rem; }

/* Product Card */
.product-card {
  background: var(--bg-white); border: 1px solid var(--border-light);
  border-radius: var(--radius); padding: 1.25rem; transition: all 0.2s;
  animation: fadeIn 0.3s ease both;
}
.product-card:hover { border-color: var(--primary-light); box-shadow: var(--shadow-md); }
.product-card.has-alert { border-left: 3px solid var(--danger); }

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.card-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 0.75rem; }
.card-info h4 { font-size: 1rem; font-weight: 700; margin-bottom: 0.2rem; }
.card-meta { display: flex; gap: 0.5rem; align-items: center; }
.platform-badge {
  padding: 0.15rem 0.5rem; border-radius: 4px;
  font-size: 0.7rem; font-weight: 600; background: var(--primary-bg); color: var(--primary);
}
.time-ago { font-size: 0.72rem; color: var(--text-light); }
.card-menu { position: relative; }
.menu-btn {
  background: none; border: none; font-size: 1.2rem; cursor: pointer;
  color: var(--text-light); padding: 0.2rem 0.4rem; border-radius: 4px; transition: all 0.15s;
}
.menu-btn:hover { background: var(--bg); color: var(--text-secondary); }
.dropdown {
  position: absolute; right: 0; top: 100%; background: var(--bg-white);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); min-width: 130px; z-index: 20; display: none;
}
.dropdown.show { display: block; }
.dropdown-item {
  display: block; width: 100%; padding: 0.5rem 0.85rem;
  font-size: 0.82rem; color: var(--text-secondary); background: none;
  border: none; text-align: left; cursor: pointer; font-family: inherit; transition: background 0.15s;
}
.dropdown-item:hover { background: var(--bg); color: var(--text-primary); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-bg); }

/* Price Display */
.price-section { margin-bottom: 0.75rem; }
.price-main { display: flex; align-items: baseline; gap: 0.6rem; margin-bottom: 0.25rem; }
.price-current { font-size: 1.6rem; font-weight: 800; color: var(--text-primary); }
.price-change { font-size: 0.82rem; font-weight: 600; padding: 0.15rem 0.45rem; border-radius: 4px; }
.price-change.down { color: var(--success); background: var(--success-bg); }
.price-change.up { color: var(--danger); background: var(--danger-bg); }
.price-change.same { color: var(--text-light); background: var(--bg); }
.price-sub { display: flex; gap: 1rem; font-size: 0.78rem; color: var(--text-light); }
.price-sub span { display: flex; align-items: center; gap: 0.25rem; }

/* Alert Badge */
.alert-badge {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.2rem 0.5rem; border-radius: 4px;
  font-size: 0.72rem; font-weight: 600; background: var(--danger-bg); color: var(--danger);
  margin-bottom: 0.5rem;
}

/* Card Actions */
.card-actions { display: flex; gap: 0.4rem; padding-top: 0.75rem; border-top: 1px solid var(--border-light); }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 1rem; backdrop-filter: blur(4px);
}
.modal {
  background: var(--bg-white); border-radius: var(--radius);
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg); animation: modalIn 0.2s ease;
}
.modal-sm { max-width: 380px; }
.modal-lg { max-width: 700px; }
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.15rem 1.5rem; border-bottom: 1px solid var(--border-light);
}
.modal-header h3 { font-size: 1.05rem; font-weight: 700; }
.modal-close {
  background: none; border: none; font-size: 1.5rem; color: var(--text-light);
  cursor: pointer; line-height: 1; padding: 0.2rem; transition: color 0.15s;
}
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 1.5rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.25rem; }

/* Form */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.82rem; font-weight: 600; margin-bottom: 0.35rem; color: var(--text-primary); }
.req { color: var(--danger); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 0.6rem 0.85rem; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 0.88rem; outline: none;
  background: var(--bg-white); color: var(--text-primary); font-family: inherit; transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg);
}
.form-group input::placeholder { color: var(--text-light); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.price-product-name { font-weight: 600; margin-bottom: 1rem; color: var(--text-primary); }

/* Chart */
.chart-container { position: relative; height: 300px; margin-bottom: 1.5rem; }
.history-table-wrap { max-height: 200px; overflow-y: auto; }
.history-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.history-table th {
  text-align: left; padding: 0.5rem 0.75rem; background: var(--bg);
  font-weight: 600; color: var(--text-secondary); position: sticky; top: 0;
}
.history-table td { padding: 0.45rem 0.75rem; border-top: 1px solid var(--border-light); }
.history-table .change-up { color: var(--danger); }
.history-table .change-down { color: var(--success); }

/* Toast */
.toast {
  position: fixed; bottom: 2rem; left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text-primary); color: white;
  padding: 0.75rem 1.5rem; border-radius: 100px; font-size: 0.88rem;
  box-shadow: var(--shadow-lg); transition: transform 0.3s ease; z-index: 300; pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* Extension Bar */
.extension-bar {
  background: linear-gradient(135deg, #6C5CE7 0%, #A29BFE 100%);
  color: white; padding: 12px 1.5rem;
}
.ext-inner { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.ext-info { display: flex; align-items: center; gap: 10px; }
.ext-icon { font-size: 1.5rem; }
.ext-info strong { display: block; font-size: 0.88rem; }
.ext-desc { font-size: 0.75rem; opacity: 0.85; }
.ext-actions { display: flex; gap: 0.5rem; }
.btn-white { background: white; color: var(--primary); border: none; }
.btn-white:hover { background: #F0EDFF; }
.btn-ghost { background: rgba(255,255,255,0.15); color: white; border: 1px solid rgba(255,255,255,0.3); }
.btn-ghost:hover { background: rgba(255,255,255,0.25); }

/* Tab Bar */
.tab-bar { background: var(--bg-white); border-bottom: 1px solid var(--border-light); padding: 0 1.5rem; }
.tab-inner { max-width: 1200px; margin: 0 auto; display: flex; gap: 0; }
.tab-btn {
  padding: 12px 20px; border: none; background: none; font-size: 0.88rem; font-weight: 500;
  color: var(--text-secondary); cursor: pointer; font-family: inherit;
  border-bottom: 2px solid transparent; transition: all 0.2s;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* Batch Bar */
.batch-bar {
  display: flex; align-items: center; gap: 1rem; padding: 10px 14px;
  background: var(--primary-bg); border-radius: var(--radius-sm); margin-bottom: 1rem;
}
.checkbox-wrap { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; cursor: pointer; }
.checkbox-wrap input { accent-color: var(--primary); width: 16px; height: 16px; }
.batch-info { font-size: 0.8rem; color: var(--text-secondary); }

/* Source badges */
.source-badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 6px; border-radius: 4px; font-size: 0.65rem; font-weight: 600;
}
.source-manual { background: #F0F0F5; color: #999; }
.source-extension { background: var(--primary-bg); color: var(--primary); }
.source-auto { background: var(--success-bg); color: var(--success); }

/* Cookie status */
.cookie-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px;
}
.cookie-dot.valid { background: var(--success); }
.cookie-dot.expired { background: var(--danger); }
.cookie-dot.none { background: #DDD; }

/* Settings Panel */
.settings-panel { max-width: 700px; margin: 0 auto; }
.settings-section {
  background: var(--bg-white); border: 1px solid var(--border-light);
  border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1rem;
}
.settings-section h3 { font-size: 1rem; font-weight: 700; margin-bottom: 4px; }
.settings-desc { font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 1rem; }
.settings-desc code { background: #E8E8EE; padding: 1px 5px; border-radius: 3px; font-size: 0.8rem; }
.settings-desc strong { color: var(--text-primary); }
.settings-form { display: flex; flex-direction: column; gap: 0; }
.settings-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }

/* Notifications */
.notifications-list { max-width: 800px; margin: 0 auto; }
.notif-item {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px;
  background: var(--bg-white); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); margin-bottom: 8px;
}
.notif-icon { font-size: 1.2rem; flex-shrink: 0; padding-top: 2px; }
.notif-body { flex: 1; }
.notif-msg { font-size: 0.88rem; color: var(--text-primary); margin-bottom: 2px; }
.notif-time { font-size: 0.72rem; color: var(--text-light); }
.notif-product { font-size: 0.75rem; color: var(--primary); }

/* Responsive */
@media (max-width: 768px) {
  .header { padding: 1.5rem 1rem; }
  .logo h1 { font-size: 1.3rem; }
  .stats-inner { gap: 1rem; }
  .stat-actions { margin-left: 0; width: 100%; }
  .stat-actions .btn { flex: 1; justify-content: center; }
  .main-content { padding: 0 1rem; }
  .products-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .modal { margin: 0.5rem; }
}

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-light); border-radius: 3px; }
