/* ===== 基础变量 ===== */
:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #232734;
    --bg-hover: #2a2f3e;
    --border: #2e3348;
    --text-primary: #e8eaed;
    --text-secondary: #9aa0b0;
    --text-muted: #6b7280;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.25);
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-primary); color: var(--text-primary);
    min-height: 100vh; line-height: 1.6;
}

/* ===== 登录/注册页面 ===== */
.auth-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: radial-gradient(ellipse at 50% 30%, rgba(99,102,241,0.08) 0%, transparent 60%);
}
.auth-card {
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius); width: 400px; max-width: 92vw;
    box-shadow: var(--shadow); overflow: hidden;
}
.auth-header { text-align: center; padding: 32px 24px 20px; }
.auth-header i { font-size: 36px; color: var(--accent); margin-bottom: 12px; display: block; }
.auth-header h1 {
    font-size: 22px; font-weight: 700;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.auth-header p { font-size: 13px; color: var(--text-muted); margin-top: 6px; }
.auth-tabs { display: flex; border-bottom: 1px solid var(--border); }
.auth-tab {
    flex: 1; padding: 12px; text-align: center; font-size: 14px; font-weight: 500;
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    transition: all 0.2s; border-bottom: 2px solid transparent;
}
.auth-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.auth-tab:hover:not(.active) { color: var(--text-secondary); }
.auth-form { padding: 24px; }
.auth-error {
    margin-top: 12px; padding: 10px 14px; background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.3); border-radius: var(--radius-sm);
    color: var(--danger); font-size: 13px; text-align: center;
}

/* ===== 布局 ===== */
.app-container { max-width: 1200px; margin: 0 auto; padding: 24px; }
.app-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 0 20px;
}
.logo { display: flex; align-items: center; gap: 12px; }
.logo i { font-size: 24px; color: var(--accent); }
.logo h1 {
    font-size: 22px; font-weight: 700;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.user-menu { display: flex; align-items: center; gap: 12px; }
.user-name { font-size: 13px; color: var(--text-secondary); }
.user-name i { margin-right: 4px; color: var(--accent); }
.main-content { display: grid; grid-template-columns: 340px 1fr; gap: 24px; }

/* ===== 面板 ===== */
.panel { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.panel-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.panel-header h2 { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.panel-header h2 i { color: var(--accent); font-size: 14px; }

/* ===== 按钮 ===== */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border: none; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.2s; white-space: nowrap; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 0 16px var(--accent-glow); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid transparent; padding: 4px 8px; }
.btn-danger:hover { background: rgba(239, 68, 68, 0.1); }
.btn-close { background: none; border: none; color: var(--text-secondary); font-size: 24px; cursor: pointer; line-height: 1; }
.btn-close:hover { color: var(--text-primary); }
.btn-block { width: 100%; justify-content: center; padding: 12px; font-size: 14px; }

/* ===== 产品列表 ===== */
.product-list { padding: 8px; max-height: calc(100vh - 200px); overflow-y: auto; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state i { font-size: 40px; margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 13px; }

.product-item {
    border-radius: var(--radius-sm); margin-bottom: 4px;
    border: 1px solid transparent; transition: all 0.15s;
}
.product-item.expanded { background: var(--bg-card); border-color: var(--border); margin-bottom: 8px; }
.product-item-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px; cursor: pointer; border-radius: var(--radius-sm);
}
.product-item-header:hover { background: var(--bg-hover); }
.product-item-info { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.product-item-toggle { color: var(--text-muted); font-size: 10px; transition: transform 0.2s; width: 16px; }
.product-item.expanded .product-item-toggle { transform: rotate(90deg); }
.product-item-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.product-item-actions { display: flex; gap: 2px; opacity: 0; transition: opacity 0.15s; }
.product-item-header:hover .product-item-actions { opacity: 1; }

/* ===== SKU 列表 ===== */
.sku-list { padding: 0 8px 8px 28px; display: none; }
.product-item.expanded .sku-list { display: block; }
.sku-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 12px; border-radius: 6px; cursor: pointer; transition: all 0.15s;
    margin-bottom: 2px; font-size: 13px;
}
.sku-item:hover { background: var(--bg-hover); }
.sku-item.active { background: rgba(99,102,241,0.12); border: 1px solid rgba(99,102,241,0.3); }
.sku-item-info { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.sku-item-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sku-badge { padding: 1px 6px; border-radius: 4px; font-size: 10px; font-weight: 500; }
.sku-badge.quota { background: rgba(99,102,241,0.15); color: var(--accent-hover); }
.sku-badge.days { background: rgba(34,197,94,0.15); color: var(--success); }
.sku-badge.mixed { background: rgba(245,158,11,0.15); color: var(--warning); }
.sku-price { font-size: 12px; color: var(--text-muted); margin-left: 4px; }
.sku-item-actions { display: flex; gap: 2px; opacity: 0; }
.sku-item:hover .sku-item-actions { opacity: 1; }
.add-sku-btn {
    display: flex; align-items: center; gap: 4px; padding: 6px 12px;
    font-size: 11px; color: var(--text-muted); cursor: pointer;
    border: 1px dashed var(--border); border-radius: 6px; background: none;
    width: 100%; justify-content: center; transition: all 0.2s; margin-top: 4px;
}

/* ===== 计算区域 ===== */
.calc-area { padding: 20px; }
.calc-placeholder { text-align: center; padding: 80px 20px; color: var(--text-muted); }
.calc-placeholder i { font-size: 48px; margin-bottom: 16px; opacity: 0.3; }
.calc-placeholder p { font-size: 14px; }
.selected-product-info {
    display: flex; flex-direction: column; gap: 4px;
    padding: 14px 18px; background: var(--bg-card); border-radius: var(--radius-sm);
    margin-bottom: 20px; border-left: 3px solid var(--accent);
}
.selected-product-info .name { font-weight: 600; font-size: 15px; }
.selected-product-info .sku-name { font-size: 13px; color: var(--accent-hover); }
.selected-product-info .url { font-size: 12px; color: var(--text-muted); word-break: break-all; }
.calc-mode h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.calc-mode h3 i { color: var(--accent); font-size: 14px; }
.mode-desc {
    font-size: 12px; color: var(--text-muted); margin-bottom: 16px;
    padding: 10px 14px; background: var(--bg-card); border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent); line-height: 1.5;
}
.divider { display: flex; align-items: center; gap: 12px; margin: 8px 0 16px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.divider span { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.optional-tag { font-size: 11px; color: var(--text-muted); font-weight: 400; margin-left: 6px; }
.query-section { margin-bottom: 4px; }

/* ===== 结果卡片 ===== */
.result-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.result-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 14px 16px; display: flex; flex-direction: column; gap: 4px;
}
.result-card .label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.result-card .value { font-size: 20px; font-weight: 700; }
.result-card .value.highlight { color: var(--accent-hover); }

/* ===== 进度条 ===== */
.progress-bar-container { height: 8px; background: var(--bg-card); border-radius: 4px; overflow: hidden; margin-bottom: 20px; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-hover)); border-radius: 4px; transition: width 0.6s ease; width: 0%; }

/* ===== 退款结果 ===== */
.refund-result, .days-result, .mixed-result, .quota-result { margin-top: 16px; }
.refund-amount {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px;
    background: linear-gradient(135deg, rgba(99,102,241,0.1), rgba(129,140,248,0.05));
    border: 1px solid rgba(99,102,241,0.3); border-radius: var(--radius);
}
.refund-amount .label { font-size: 14px; color: var(--text-secondary); }
.refund-amount .value { font-size: 32px; font-weight: 800; color: var(--success); }

/* ===== 弹窗 ===== */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.modal { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); width: 480px; max-width: 90vw; box-shadow: var(--shadow); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 24px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--border); }

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== 加载 & Toast ===== */
.loading-spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast-container { position: fixed; top: 24px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 20px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; box-shadow: var(--shadow); animation: slideIn 0.3s ease; display: flex; align-items: center; gap: 8px; }
.toast.success { background: var(--success); color: #fff; }
.toast.error { background: var(--danger); color: #fff; }
.toast.info { background: var(--accent); color: #fff; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .main-content { grid-template-columns: 1fr; }
    .product-list { max-height: 300px; }
    .app-container { padding: 12px; }
    .result-grid { grid-template-columns: 1fr 1fr; }
    .app-header { flex-direction: column; gap: 12px; }
}
.add-sku-btn:hover { color: var(--accent); border-color: var(--accent); background: rgba(99,102,241,0.05); }

/* ===== 表单 ===== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.required { color: var(--danger); }
input[type="text"], input[type="number"], input[type="password"] {
    width: 100%; padding: 10px 14px; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text-primary); font-size: 14px; transition: border-color 0.2s;
}
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; }
.help-text { display: block; font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.radio-group { display: flex; gap: 12px; }
.radio-group-3 { flex-wrap: wrap; }
.radio-label {
    flex: 1; display: flex; align-items: center; gap: 8px;
    padding: 12px 16px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); cursor: pointer; transition: all 0.2s;
}
.radio-label:has(input:checked) { border-color: var(--accent); background: rgba(99,102,241,0.08); }
.radio-label input { display: none; }
.radio-label span { display: flex; align-items: center; gap: 6px; font-size: 13px; }

