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

:root {
  --bg: #f5f6fa; --surface: #fff; --text: #1a1a2e; --text-secondary: #6b7280; --text-light: #9ca3af;
  --border: #e5e7eb; --primary: #4f46e5; --primary-hover: #4338ca; --primary-light: #eef2ff;
  --warn: #f59e0b; --warn-bg: #fffbeb; --danger: #ef4444; --danger-bg: #fef2f2;
  --success: #10b981; --success-bg: #ecfdf5;
  --shadow: 0 1px 3px rgba(0,0,0,0.08); --radius: 12px; --radius-sm: 8px; --sidebar-w: 220px;
}

body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6; }
.hidden { display: none !important; }

/* ============ Login ============ */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%); }
.login-card { background: var(--surface); border-radius: 16px; padding: 40px 36px; width: 380px; max-width: 92vw; box-shadow: 0 20px 60px rgba(0,0,0,0.3); text-align: center; }
.login-logo { font-size: 44px; margin-bottom: 8px; }
.login-card h1 { font-size: 20px; margin-bottom: 24px; }
.login-form { text-align: left; }
.login-error { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 18px; text-align: center; }
.btn-block { width: 100%; justify-content: center; }

/* ============ Layout ============ */
#app { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100; transition: transform .3s; }
.sidebar-header { padding: 24px 20px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); }
.logo { font-size: 26px; } .sidebar-title { font-size: 19px; font-weight: 700; }
.sidebar-nav { flex: 1; padding: 12px 8px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: var(--radius-sm); text-decoration: none; color: var(--text-secondary); font-weight: 500; transition: all .15s; margin-bottom: 2px; }
.nav-item:hover { background: var(--primary-light); color: var(--primary); }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-icon { font-size: 17px; width: 22px; text-align: center; }
.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.main-content { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; }
.topbar { height: 56px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 24px; gap: 16px; position: sticky; top: 0; z-index: 50; }
.menu-toggle { display: none; background: none; border: none; font-size: 20px; cursor: pointer; }
.topbar-title { font-size: 18px; font-weight: 600; flex: 1; }
.page-content { padding: 24px; flex: 1; }

/* ============ Cards ============ */
.summary-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.summary-card { background: var(--surface); border-radius: var(--radius); padding: 20px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.card-icon { font-size: 26px; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; border-radius: 12px; background: var(--bg); }
.card-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.card-value { font-size: 22px; font-weight: 700; }
.card-open .card-icon { background: var(--primary-light); } .card-open .card-value { color: var(--primary); }
.card-deal .card-icon { background: var(--success-bg); } .card-deal .card-value { color: var(--success); }
.card-amount .card-icon { background: #fdf2f8; } .card-amount .card-value { color: #db2777; }
.card-rate .card-icon { background: var(--warn-bg); } .card-rate .card-value { color: var(--warn); }

/* ============ Charts ============ */
.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.chart-card { background: var(--surface); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.chart-card.full-width { margin-bottom: 24px; }
.chart-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.chart-header h3 { font-size: 16px; font-weight: 600; }
.chart-body { height: 250px; position: relative; }
.chart-body.tall { height: 280px; }

/* ============ Dashboard lists ============ */
.dashboard-lists { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.list-card { background: var(--surface); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.section-header h3 { font-size: 15px; font-weight: 600; }
.badge { font-size: 12px; padding: 2px 10px; border-radius: 20px; font-weight: 600; }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.mini-list { display: flex; flex-direction: column; gap: 8px; }
.mini-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; transition: background .1s; }
.mini-item:hover { background: var(--bg); }
.mini-item.overdue { border-color: var(--danger); background: var(--danger-bg); }
.mini-item-title { flex: 1; min-width: 0; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-item-sub { font-size: 12px; color: var(--text-light); }
.mini-date { font-size: 12px; color: var(--text-secondary); white-space: nowrap; }
.mini-date.overdue { color: var(--danger); font-weight: 700; }
.empty-mini { text-align: center; color: var(--text-light); padding: 16px; font-size: 13px; }

/* ============ Inquiry list ============ */
.filter-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-select, .filter-input { padding: 7px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); font-size: 13px; color: var(--text); }
.search-input { width: 240px; }
.filter-sep { color: var(--text-light); }
.inquiry-list { display: flex; flex-direction: column; gap: 10px; }
.inquiry-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; cursor: pointer; transition: all .15s; box-shadow: var(--shadow); display: flex; gap: 14px; align-items: flex-start; }
.inquiry-item:hover { border-color: var(--primary); }
.iq-main { flex: 1; min-width: 0; }
.iq-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.iq-company { font-weight: 700; font-size: 15px; }
.iq-product { font-size: 13px; color: var(--text-secondary); }
.iq-meta { font-size: 12px; color: var(--text-light); display: flex; gap: 14px; flex-wrap: wrap; }
.iq-right { text-align: right; white-space: nowrap; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.iq-value { font-weight: 700; color: #db2777; }
.status-tag { font-size: 12px; padding: 2px 10px; border-radius: 20px; font-weight: 600; display: inline-block; }
.st-新询盘 { background: var(--primary-light); color: var(--primary); }
.st-跟进中 { background: #eff6ff; color: #2563eb; }
.st-已报价 { background: #fdf4ff; color: #a21caf; }
.st-谈判中 { background: var(--warn-bg); color: var(--warn); }
.st-已成交 { background: var(--success-bg); color: var(--success); }
.st-已流失 { background: #f3f4f6; color: #6b7280; }
.pri-tag { font-size: 11px; padding: 1px 8px; border-radius: 20px; font-weight: 600; }
.pr-紧急 { background: var(--danger-bg); color: var(--danger); }
.pr-高 { background: var(--warn-bg); color: var(--warn); }
.pr-普通 { background: var(--bg); color: var(--text-secondary); }
.pr-低 { background: var(--bg); color: var(--text-light); }
.source-tag { font-size: 11px; color: var(--text-light); }
.alibaba-tag { color: #f60; font-weight: 600; }

/* ============ Detail ============ */
.detail-wrap { margin-top: 16px; display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; }
.detail-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.detail-panel h3 { font-size: 15px; font-weight: 600; margin-bottom: 14px; }
.detail-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.detail-row:last-child { border-bottom: none; }
.detail-row .k { color: var(--text-secondary); white-space: nowrap; }
.detail-row .v { text-align: right; word-break: break-all; font-weight: 500; }
.status-flow { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0; }
.flow-btn { padding: 5px 12px; border-radius: 20px; border: 1px solid var(--border); background: var(--surface); font-size: 12px; cursor: pointer; color: var(--text-secondary); }
.flow-btn.current { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.requirements-box { background: var(--bg); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 13px; white-space: pre-wrap; word-break: break-word; max-height: 260px; overflow-y: auto; margin-top: 8px; }
.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ''; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding: 0 0 18px 12px; }
.tl-item::before { content: ''; position: absolute; left: -19px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--primary); }
.tl-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.tl-action { font-weight: 600; font-size: 13px; }
.tl-time { font-size: 12px; color: var(--text-light); }
.tl-content { font-size: 13px; color: var(--text-secondary); }
.tl-next { font-size: 12px; margin-top: 4px; color: var(--warn); font-weight: 500; }

/* ============ Customer list ============ */
.customer-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.customer-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; box-shadow: var(--shadow); }
.cust-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.cust-name { font-weight: 700; font-size: 15px; }
.cust-actions { display: flex; gap: 4px; }
.icon-btn { width: 28px; height: 28px; border: none; border-radius: 6px; background: var(--bg); cursor: pointer; font-size: 13px; display: flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--border); }
.cust-row { font-size: 13px; color: var(--text-secondary); display: flex; gap: 8px; padding: 2px 0; }
.cust-stats { display: flex; gap: 16px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 12px; }
.cust-stats b { color: var(--primary); }

/* ============ Buttons / Forms ============ */
.btn { padding: 8px 16px; border: none; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; cursor: pointer; transition: all .15s; display: inline-flex; align-items: center; gap: 6px; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-add { width: 100%; justify-content: center; padding: 10px; font-size: 15px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.required { color: var(--danger); }
.form-input { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; color: var(--text); background: var(--surface); font-family: inherit; }
.form-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.textarea { resize: vertical; }
.form-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.cust-toggle { display: flex; gap: 18px; margin-bottom: 10px; }
.radio-label { font-size: 13px; color: var(--text); font-weight: 500; display: flex; align-items: center; gap: 5px; cursor: pointer; }
.new-cust-form { display: flex; flex-direction: column; gap: 10px; }

/* ============ Modal / Toast / Empty ============ */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 200; animation: fadeIn .15s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--surface); border-radius: var(--radius); width: 460px; max-width: 92vw; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,0.2); animation: slideUp .2s; }
.modal-lg { width: 620px; }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header { padding: 16px 24px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { font-size: 17px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text-light); line-height: 1; width: 28px; height: 28px; border-radius: 6px; }
.modal-close:hover { background: var(--bg); }
.modal-body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(100px); background: #1a1a2e; color: #fff; padding: 10px 24px; border-radius: var(--radius-sm); font-size: 14px; z-index: 300; opacity: 0; transition: all .3s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: #10b981; } .toast.error { background: var(--danger); }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-secondary); background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); }
.empty-icon { font-size: 44px; margin-bottom: 10px; }

/* ============ Settings ============ */
.settings-section { background: var(--surface); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); border: 1px solid var(--border); margin-bottom: 16px; max-width: 520px; }
.settings-section h3 { font-size: 15px; font-weight: 600; margin-bottom: 14px; }
.settings-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.settings-item:last-child { border-bottom: none; }
.settings-label { font-weight: 600; font-size: 14px; }
.settings-desc { font-size: 12px; color: var(--text-light); margin-top: 2px; }
.about-text { color: var(--text-secondary); font-size: 13px; line-height: 1.8; }
.password-form { max-width: 360px; }

/* ============ Responsive ============ */
@media (max-width: 900px) {
  .charts-row, .dashboard-lists, .detail-wrap { grid-template-columns: 1fr; }
  .form-row3 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .menu-toggle { display: block; }
  .summary-cards { grid-template-columns: 1fr 1fr; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .search-input { width: 100%; }
}

/* ============ v1.1: Excel 对齐新增样式 ============ */
.st-未报价 { background: #f3f4f6; color: #6b7280; }
.st-已报价 { background: #fdf4ff; color: #a21caf; }
.st-已报价跟进中 { background: #eff6ff; color: #2563eb; }
.st-已报价待追询 { background: var(--primary-light); color: var(--primary); }
.st-已付款待发货 { background: var(--warn-bg); color: var(--warn); }
.st-已发货 { background: #ecfeff; color: #0891b2; }
.st-已成交 { background: var(--success-bg); color: var(--success); }

.grade-tag { font-size: 11px; padding: 1px 8px; border-radius: 20px; font-weight: 700; }
.gr-S { background: #fee2e2; color: #dc2626; }
.gr-A { background: #fff7ed; color: #ea580c; }
.gr-B { background: #f0fdf4; color: #16a34a; }

.iq-todo { font-size: 13px; color: #b45309; background: #fffbeb; border-radius: 6px; padding: 3px 8px; margin: 4px 0; display: inline-block; }
.stalled-badge { font-size: 12px; color: #dc2626; background: #fee2e2; border-radius: 20px; padding: 2px 10px; font-weight: 700; white-space: nowrap; }
.next-date { font-size: 12px; color: #4f46e5; white-space: nowrap; }
.next-date.overdue { color: #dc2626; font-weight: 700; }
.overdue-text { color: #dc2626; font-weight: 700; }
.todo-filter { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--text-secondary); white-space: nowrap; }
.tl-problem { font-size: 13px; color: #b45309; margin-top: 4px; }
.tl-idea { font-size: 13px; color: #0e7490; margin-top: 2px; }
