/* ============================================================
   BINGYEN 发票管理 — 样式
   改颜色先改 site-config.json 里的 brand，或者在下面改 :root 变量。
   ============================================================ */

:root {
	--primary: #2d7dd2;
	--accent: #4a9eff;
	--dark: #1a2332;
	--bg: #f4f6fa;
	--sidebar: #1a2332;
	--sidebar-text: #c7d2e3;
	--panel: #ffffff;
	--border: #e4e9f2;
	--text: #1f2937;
	--muted: #6b7280;
	--ok: #16a34a;
	--warn: #d97706;
	--danger: #dc2626;
	--radius: 12px;
	--shadow: 0 2px 10px rgba(20, 30, 50, 0.06);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
	font-family: "Segoe UI", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
	background: var(--bg);
	color: var(--text);
	font-size: 14px;
	line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.boot { padding: 60px; text-align: center; color: var(--muted); }

/* ---------- 登录门 ---------- */
.login-wrap {
	min-height: 100vh;
	display: grid;
	place-items: center;
	background: linear-gradient(160deg, #12243c, #1a2f4d);
	padding: 20px;
}
.login-card {
	background: #fff;
	border-radius: 16px;
	padding: 36px;
	width: 100%;
	max-width: 380px;
	box-shadow: var(--shadow);
	text-align: center;
}
.login-logo { font-size: 44px; margin-bottom: 8px; }
.login-card h1 { font-size: 20px; margin: 6px 0 2px; }
.login-card p { color: var(--muted); margin: 0 0 20px; font-size: 13px; }
.login-card input {
	width: 100%;
	padding: 12px;
	border: 1px solid var(--border);
	border-radius: 10px;
	font-size: 15px;
	margin-bottom: 12px;
}
.login-err { color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 8px; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
	width: 230px;
	background: var(--sidebar);
	color: var(--sidebar-text);
	flex-shrink: 0;
	padding: 22px 14px;
	position: sticky;
	top: 0;
	height: 100vh;
	display: flex;
	flex-direction: column;
	gap: 6px;
}
.sidebar-logo { display: flex; align-items: center; gap: 12px; padding: 0 8px 18px; }
.sidebar-logo img { width: auto; height: 38px; max-width: 46px; object-fit: contain; }
.sidebar-logo h1 { font-size: 16px; color: #fff; margin: 0; font-weight: 600; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar nav a {
	color: var(--sidebar-text);
	padding: 11px 12px;
	border-radius: 9px;
	font-size: 14px;
	display: block;
}
.sidebar nav a:hover { background: rgba(255, 255, 255, 0.07); text-decoration: none; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.sidebar-foot { display: flex; gap: 8px; flex-direction: column; }
.sidebar-foot button {
	background: transparent;
	border: 1px solid rgba(255, 255, 255, 0.15);
	color: var(--sidebar-text);
	padding: 9px;
	border-radius: 9px;
	cursor: pointer;
	font-size: 13px;
}
.sidebar-foot button:hover { background: rgba(255, 255, 255, 0.07); }

.main { flex: 1; padding: 26px; min-width: 0; }
.page-title { font-size: 22px; margin: 0 0 4px; }
.page-sub { color: var(--muted); margin: 0 0 22px; }

/* ---------- 面板 / 卡片 ---------- */
.grid { display: grid; gap: 18px; }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.panel {
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 22px;
	box-shadow: var(--shadow);
}
.panel h2 { font-size: 16px; margin: 0 0 16px; }
.stat .stat-label { color: var(--muted); font-size: 13px; }
.stat .stat-value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat .stat-value.warn { color: var(--warn); }
.stat .stat-value.ok { color: var(--ok); }
.stat .stat-value.danger { color: var(--danger); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.table-wrap th { white-space: nowrap; }
.table-wrap td { white-space: normal; overflow-wrap: break-word; word-break: break-word; }
.table-wrap .num, .table-wrap td:last-child { white-space: nowrap; }
th { background: #f8fafc; color: var(--muted); font-weight: 600; font-size: 12.5px; }
td.right, th.right { text-align: right; }
tr:last-child td { border-bottom: none; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* 列表行 hover 效果（发票 / 报价单 / 客户） */
table.list-table tbody tr { transition: background-color .15s ease, box-shadow .15s ease, border-color .15s ease; }
table.list-table tbody tr:hover { background: #eef4ff; }
table.list-table tbody tr:hover td { border-bottom-color: #d7e3fb; }

/* ---------- 导入付款 ---------- */
.drop-zone { border: 2px dashed var(--border); border-radius: var(--radius); background: #fff; padding: 34px 20px; text-align: center; transition: border-color .15s ease, background-color .15s ease; }
.drop-zone.drag { border-color: var(--primary); background: #eef4ff; }
.drop-zone .drop-icon { display: inline-flex; align-items: center; justify-content: center; width: 54px; height: 54px; border-radius: 12px; background: #eef4ff; color: var(--primary); font-weight: 700; font-size: 15px; margin-bottom: 10px; }
.drop-zone p { color: var(--muted); margin: 0 0 4px; }
.import-card { margin-bottom: 14px; }
.import-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.import-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px 16px; margin-bottom: 12px; }
.import-fields > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.import-fields span { color: var(--muted); font-size: 12px; }
.import-fields b { font-size: 14px; overflow-wrap: anywhere; }
.import-match { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.import-match select { flex: 1 1 320px; min-width: 0; }
.import-match label { color: var(--muted); font-size: 12px; font-weight: 600; }
.import-actions { display: flex; gap: 10px; }
.payment-files { display: flex; flex-direction: column; gap: 8px; }
.payment-file { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.payment-file a { font-weight: 600; }

/* ---------- 客户排行榜 ---------- */
.rank-top { font-size: 16px !important; line-height: 1.35; }
.rank-table td { vertical-align: middle; }
.rank-table td[data-action] { cursor: pointer; }
.rank-pos { text-align: center; width: 58px; }
.rank-medal { font-size: 18px; }
.rank-num { display: inline-block; min-width: 22px; color: var(--muted); font-weight: 600; }
.rank-caret { color: var(--muted); }
.rank-row.open { background: #f8fafc; }
.rank-detail > td { padding: 0 !important; background: #f8fafc; }
.rank-detail-inner { padding: 12px 14px 16px; }
.rank-detail-inner .list-table { background: #fff; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.rank-detail-inner .list-table th, .rank-detail-inner .list-table td { padding: 8px 12px; }

/* ---------- 对账单 ---------- */
.statement-table { table-layout: fixed; }
.statement-table th:nth-child(3), .statement-table td:nth-child(3) { text-align: left; }
.statement-table .money-value { text-align: right; font-variant-numeric: tabular-nums; }

/* 合计区：单一 2 栏 Grid，标签右侧对齐、金额右侧对齐，线宽与整区一致 */
.statement-summary {
	width: min(100%, 440px);
	margin: 20px 0 0 auto;
}
.statement-summary .ss-rule { height: 1px; background: var(--border); }
.statement-summary .ss-row {
	display: grid;
	grid-template-columns: 1fr 170px;
	align-items: baseline;
	column-gap: 14px;
	padding: 7px 0;
}
.statement-summary .ss-label {
	text-align: right;
	color: var(--muted);
	font-size: 13px;
}
.statement-summary .ss-amt {
	text-align: right;
	font-variant-numeric: tabular-nums;
	color: #13315f;
	font-size: 13px;
	font-weight: 600;
}
.statement-summary .ss-total { padding-top: 9px; }
.statement-summary .ss-total .ss-label,
.statement-summary .ss-total .ss-amt {
	color: #13315f;
	font-size: 16px;
	font-weight: 700;
}
.table-paid { display: block; margin-top: 3px; color: var(--ok); font-size: 11px; font-weight: 500; }
.empty-row { text-align: center; color: var(--muted); padding: 40px !important; }

/* ---------- 状态徽章 ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.pending { background: #fef3c7; color: #92400e; }
.badge.deposit { background: #e0e7ff; color: #3730a3; }
.badge.paid { background: #d1fae5; color: #065f46; }
.badge.overdue { background: #fee2e2; color: #991b1b; }
.badge.draft { background: #e5e7eb; color: #374151; }
.badge.sent { background: #dbeafe; color: #1e40af; }
.badge.accepted { background: #d1fae5; color: #065f46; }
.badge.rejected { background: #fee2e2; color: #991b1b; }

/* ---------- 按钮 ---------- */
.btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 9px 16px;
	border: 1px solid transparent;
	border-radius: 9px;
	font-size: 14px;
	cursor: pointer;
	background: #f3f4f6;
	color: var(--text);
	font-weight: 500;
}
.btn:hover { filter: brightness(0.97); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn.small { padding: 6px 10px; font-size: 12.5px; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar-actions { display: flex; gap: 8px; }
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.form-grid .full { grid-column: 1 / -1; }
label.field { display: flex; flex-direction: column; gap: 6px; }
label.field > span { font-size: 13px; color: var(--muted); font-weight: 500; }
input, select, textarea {
	width: 100%;
	padding: 10px 12px;
	border: 1px solid var(--border);
	border-radius: 9px;
	font-size: 14px;
	font-family: inherit;
	background: #fff;
}
textarea { resize: vertical; min-height: 84px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); margin: 22px 0 12px; }

/* ---------- 项目明细（SaaS 风格 Grid 编辑器） ---------- */
.items-editor { border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.items-head,
.item-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) 110px 180px 170px 40px; gap: 12px; align-items: start; }
.items-head { padding: 12px 16px; background: #f8fafc; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 12.5px; font-weight: 600; border-radius: 12px 12px 0 0; }
.items-head .right { text-align: right; }
.items-body { display: block; }
.item-row { padding: 18px 16px; }
.item-row + .item-row { border-top: 1px solid #eef1f6; }
.item-row .it-col { min-width: 0; }
.items-editor textarea,
.items-editor input { width: 100%; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.items-editor textarea:focus,
.items-editor input:focus { outline: 3px solid var(--ring); border-color: var(--primary); }
.it-no { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; text-align: right; padding-top: 11px; }
.it-desc textarea { min-height: 80px; overflow-y: hidden; resize: vertical; line-height: 1.55; }
.it-amt { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); padding-top: 11px; white-space: nowrap; }
.it-act { display: flex; justify-content: flex-end; padding-top: 6px; }
.item-del { width: 30px; height: 30px; padding: 0; display: inline-flex; align-items: center; justify-content: center; background: transparent; border: 1px solid var(--border); border-radius: 8px; color: var(--muted); font-size: 15px; line-height: 1; cursor: pointer; }
.item-del:hover { color: var(--danger); border-color: var(--danger); background: #fef2f2; }

/* 合计：与金额列对齐，不做整条色带，保持简洁 */
.items-summary { display: grid; grid-template-columns: minmax(0, 1fr) 120px 180px 170px 44px; gap: 12px; align-items: baseline; padding: 18px 16px; border-top: 1px solid var(--border); }
.items-summary-label { grid-column: 1 / 4; text-align: right; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.items-summary-value { grid-column: 4 / 5; text-align: right; color: var(--sheet-heading); font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.items-summary-value .cur { font-size: 14px; font-weight: 600; margin-right: 3px; }
.add-item-btn { margin-top: 12px; }

/* ---------- 发票 / 报价单（A4 纸张式预览，还原原版） ---------- */
.invoice-page { padding: 28px; font-family: Arial, "Microsoft YaHei", sans-serif; }
.invoice-page .toolbar { width: min(100%, 210mm); margin: 0 auto 18px; }
.invoice-sheet { background: #fff; width: 210mm; min-height: 297mm; box-shadow: 0 14px 40px rgba(20,30,50,.12); margin: auto; padding: 16mm 17mm; display: flex; flex-direction: column; }
.invoice-sheet h1 { color: #13315f; letter-spacing: .3px; margin: 0 0 2px; font-size: 20px; }
.invoice-sheet p { margin: 4px 0; font-size: 11px; line-height: 1.5; }
.invoice-sheet .section { margin-top: 24px; }
.invoice-sheet .section h2 { color: #13315f; text-transform: uppercase; letter-spacing: .6px; margin: 0 0 10px; font-size: 14px; }
.invoice-sheet table { table-layout: fixed; border-collapse: separate; border-spacing: 0; border-radius: 10px; width: 100%; font-size: 11px; overflow: hidden; }
.invoice-sheet th { background: #e4f0ff; color: #183158; padding: 9px 8px; }
.invoice-sheet td { vertical-align: top; padding: 10px 8px; }
.invoice-sheet th:nth-child(n+3), .invoice-sheet td:nth-child(n+3) { text-align: right; }
.invoice-header { border-bottom: 1px solid #dbe1e9; grid-template-columns: 1.35fr .65fr; align-items: start; gap: 28px; padding-bottom: 22px; display: grid; }
.company-logo { object-fit: contain; max-width: 200px; max-height: 64px; margin: 0 0 12px; display: block; }
.invoice-meta { text-align: right; align-self: end; }
.invoice-meta h1 { letter-spacing: 1px; margin-bottom: 14px; font-size: 28px; }
.meta-row { grid-template-columns: 110px 1fr; gap: 12px; padding: 5px 0; font-size: 11px; display: grid; }
.meta-row span:first-child { color: #6d7787; text-align: right; }
.invoice-items-title { margin-bottom: 9px; font-size: 13px; text-transform: none !important; letter-spacing: .15px !important; }
.contact-line { grid-template-columns: 20px minmax(0, 1fr); align-items: start; gap: 7px; display: grid; }
.contact-icon { width: 18px; height: 18px; color: #245fe5; border-radius: 5px; place-items: center; display: inline-grid; }
.contact-icon svg { stroke-width: 1.8px; width: 11px; height: 11px; display: block; }
.totals-box { width: 285px; margin: 18px 0 0 auto; }
.total-row { border-top: 1px solid #d0d8e2; justify-content: flex-end; align-items: center; gap: 16px; padding: 9px 4px; font-size: 11px; display: flex; }
.total-row.grand-total { color: #13315f; border-top: none; font-size: 14px; font-weight: 700; }
.money-value, .grand-amount { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.invoice-footer { border-top: 1px solid #dbe1e9; margin-top: auto; padding-top: 18px; }
.remarks h2 { color: #6d7787; letter-spacing: .7px; text-transform: uppercase; margin: 0 0 8px; font-size: 9px; font-weight: 700; }
.col-no { width: 7%; }
.col-description { width: 53%; }
.col-qty { width: 10%; }
.col-value { width: 15%; }

.internal-panel { border: 1px solid #dbe1e9; background: #fff; width: min(100%, 210mm); box-shadow: 0 8px 24px rgba(20,30,50,.06); border-radius: 10px; margin: 18px auto 0; padding: 18px 20px; }
.internal-panel h2 { color: #13315f; margin: 0 0 12px; font-size: 15px; }
.internal-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px 20px; }
.internal-grid > div { display: flex; flex-direction: column; gap: 6px; }
.internal-grid span { color: #6d7787; font-size: 12px; }
.internal-grid strong, .internal-grid p { margin: 0; font-size: 12px; }

/* ---------- 移动端 ---------- */
@media (max-width: 820px) {
	body { overflow-x: hidden; }
	.layout { flex-direction: column; }
	.main { padding: 14px; min-width: 0; }
	.page-title { font-size: 20px; }
	.page-sub { margin-bottom: 16px; }

	/* 顶栏（原侧边栏）改成两行紧凑头部 */
	.sidebar { width: 100%; height: auto; position: static; flex-direction: column; align-items: stretch; padding: 10px 12px; gap: 6px; }
	.sidebar-logo { padding: 0; gap: 10px; }
	.sidebar-logo img { height: 34px; max-width: 42px; }
	.sidebar-logo h1 { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
	.sidebar nav { flex-direction: row; overflow-x: auto; gap: 6px; -webkit-overflow-scrolling: touch; }
	.sidebar nav a { white-space: nowrap; padding: 9px 12px; font-size: 14px; }
	.sidebar-foot { flex-direction: row; }
	.sidebar-foot button { flex: 1; white-space: nowrap; }

	/* 表单 / 统计卡 */
	.form-grid { grid-template-columns: 1fr; }
	.grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.grid.cols-2 { grid-template-columns: 1fr; }
	.grid .stat { min-width: 0; }
	.stat .stat-value { font-size: 20px; }

	/* 宽表格：横向滑动，避免列塌陷成竖条 */
	.table-wrap { overflow-x: auto; }
	.table-wrap th, .table-wrap td { white-space: normal; }
	.table-wrap table { min-width: 860px; }
	.table-wrap .num, .table-wrap td:last-child { white-space: nowrap; }

	/* 客户 / 发票 / 报价单列表：手机端卡片式（无需横向滑动） */
	.table-wrap table.list-table { min-width: 0; }
	table.list-table { display: block; width: 100%; }
	table.list-table thead { display: none; }
	table.list-table tbody { display: block; }
	table.list-table tr { display: block; margin: 0 0 12px; padding: 4px 12px 10px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
	table.list-table tr:hover, table.list-table tr:active { border-color: #b9cef6; box-shadow: 0 6px 18px rgba(36, 95, 229, 0.12); }
	table.list-table td { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; border-bottom: 1px solid #f0f2f7; white-space: normal; }
	table.list-table td:last-child { border-bottom: none; white-space: normal; }
	table.list-table td::before { content: attr(data-label); flex: 0 0 78px; color: var(--muted); font-size: 12px; font-weight: 600; padding-top: 2px; }
	table.list-table td:first-child { display: block; font-weight: 700; font-size: 15px; padding: 10px 0 4px; }
	table.list-table td:first-child::before { content: none; }
	table.list-table td .btn { white-space: nowrap; }
	table.list-table td .num { white-space: nowrap; }

	/* 概览月度明细：适配手机宽度，金额列不被挡住 */
	table.monthly-table { min-width: 0; }
	table.monthly-table th, table.monthly-table td { padding: 8px 6px; font-size: 12px; }

	/* 发票 / 报价单 / 对账单：手机端按比例缩放为整页预览（由 JS 设 zoom），与 PDF 保持一致 */
	.invoice-page { padding: 12px 10px; }
	.invoice-page .toolbar { width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
	.invoice-page .toolbar .toolbar-actions { flex-wrap: wrap; }
	.invoice-sheet { transform-origin: top left; }

	/* 工具栏 / 登录 */
	.toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
	.toolbar-actions { flex-wrap: wrap; }
	.toolbar input { width: 100%; }
	.login-card { max-width: 340px; }
}

/* ---------- 打印 / PDF ---------- */
@page { size: A4; margin: 0; }
@media print {
	html, body { width: 210mm; min-width: 210mm; background: #fff !important; margin: 0 !important; padding: 0 !important; }
	.invoice-page { padding: 0 !important; }
	.sidebar, .toolbar, .internal-panel { display: none !important; }
	.invoice-sheet { display: block !important; width: 210mm !important; min-height: auto !important; box-shadow: none !important; margin: 0 !important; padding: 16mm 17mm !important; zoom: 1 !important; }
	.invoice-sheet thead { display: table-header-group; }
	.invoice-header, .bill-to, .invoice-sheet tr, .totals-box, .invoice-footer { break-inside: avoid; page-break-inside: avoid; }
	.invoice-header { grid-template-columns: 1.35fr .65fr !important; display: grid !important; }
	.invoice-meta { text-align: right !important; }
	.invoice-sheet .section { margin-top: 16px; }
	.invoice-header { padding-bottom: 14px; }
	.invoice-sheet td { padding: 8px 8px; }
	.total-row { padding: 6px 4px; }
	.invoice-footer { padding-top: 14px; }
	*, :before, :after { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- 每月收入直方图（堆叠：实收 + 未收 = 开单） ---------- */
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.chart-legend { display: flex; align-items: center; gap: 16px; font-size: 12px; color: var(--muted); }
.chart-legend .lg-item { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .lg { display: inline-block; width: 11px; height: 11px; border-radius: 2px; }
.chart-legend .lg-received { background: var(--ok); }
.chart-legend .lg-outstanding { background: var(--danger); }
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 240px; }
.bar-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; }
.bar-track { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; width: 100%; height: 210px; }
.bar-value { margin-bottom: 4px; font-size: 10px; line-height: 1; color: var(--muted); white-space: nowrap; }
.bar-stack { display: flex; flex-direction: column; width: 52%; max-width: 26px; border-radius: 4px 4px 0 0; overflow: hidden; }
.bar-seg { width: 100%; }
.bar-out { background: var(--danger); }
.bar-rec { background: var(--ok); }
.bar-label { margin-top: 8px; font-size: 10px; color: var(--muted); white-space: nowrap; }
.bar-col:hover .bar-stack { opacity: 0.88; }

/* 每月收入柱状图：从下往上生长（错峰入场） */
@keyframes bar-grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes bar-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.bar-stack { transform-origin: bottom; animation: bar-grow .65s cubic-bezier(.22, .68, .32, 1) both; }
.bar-value { animation: bar-fade .5s ease both; }
.bar-label { animation: bar-fade .5s ease both; }
@media (prefers-reduced-motion: reduce) {
	.bar-stack, .bar-value, .bar-label { animation: none; }
}
@media (max-width: 820px) {
	.bar-chart { height: 190px; gap: 3px; }
	.bar-track { height: 165px; }
	.bar-value { font-size: 9px; }
	.bar-label { font-size: 9px; }
}

/* ---------- 搜索框 ---------- */
.search-input { flex: 1 1 240px; min-width: 180px; max-width: 360px; }
.rank-inline { display: none; }

/* ---------- 手机版优化 ---------- */
@media (max-width: 820px) {
	/* 搜索框占满整行 */
	.search-input { flex: 1 1 100%; width: 100%; max-width: 100%; }

	/* 列表卡片：金额/数字与其它字段统一左对齐（避免只有金额靠右） */
	table.list-table td.right,
	table.list-table td.num,
	table.list-table th.right { text-align: left; }

	/* 排行榜统计卡更紧凑 */
	.grid.cols-3 .panel.stat { padding: 14px 16px; }
	.rank-top { font-size: 15px !important; }

	/* 排行榜：每行一张卡片 */
	.rank-table { display: block; width: 100%; }
	.rank-table thead { display: none; }
	.rank-table tbody { display: block; }
	.rank-table tr.rank-row { display: block; margin: 0 0 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
	.rank-table tr.rank-row td { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid #f0f2f7; text-align: left !important; white-space: normal; }
	.rank-table tr.rank-row td:last-child { border-bottom: none; padding-bottom: 2px; }
	.rank-table tr.rank-row td::before { content: attr(data-label); flex: 0 0 auto; color: var(--muted); font-size: 12px; font-weight: 600; }
	.rank-table tr.rank-row td.rank-pos { display: none; }
	.rank-table tr.rank-row td.rank-cust { display: block; padding: 2px 0 8px; border-bottom: 1px solid #f0f2f7; font-size: 15px; }
	.rank-table tr.rank-row td.rank-cust::before { content: none; }
	.rank-inline { display: inline-block; margin-right: 6px; }
	.rank-table tr.rank-row.open { margin-bottom: 0; border-radius: 10px 10px 0 0; }

	/* 展开的发票：接在卡片下方，紧凑两列 */
	.rank-detail { display: block; }
	.rank-detail > td { display: block !important; padding: 0 !important; border: none !important; }
	.rank-detail-inner { padding: 10px 14px 12px; margin: 0 0 12px; border: 1px solid var(--border); border-top: none; border-radius: 0 0 10px 10px; background: #f8fafc; }
	.rank-detail-inner .list-table { display: block; background: transparent; border: none; border-radius: 0; overflow: visible; }
	.rank-detail-inner .list-table thead { display: none; }
	.rank-detail-inner .list-table tbody { display: block; }
	.rank-detail-inner .list-table tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 9px 0; border: none; border-bottom: 1px solid #e6eaf1; margin: 0; }
	.rank-detail-inner .list-table tr:last-child { border-bottom: none; }
	.rank-detail-inner .list-table td { display: block; padding: 0 !important; border: none; white-space: normal; }
	.rank-detail-inner .list-table td::before { content: none; }
	.rank-detail-inner .list-table td:nth-child(1) { grid-column: 1; grid-row: 1; font-weight: 600; }
	.rank-detail-inner .list-table td:nth-child(2) { grid-column: 2; grid-row: 1; text-align: right; color: var(--muted); font-size: 12px; }
	.rank-detail-inner .list-table td:nth-child(3) { grid-column: 1; grid-row: 2; }
	.rank-detail-inner .list-table td:nth-child(4) { grid-column: 2; grid-row: 2; text-align: right; }

	/* 项目明细：手机端每个项目一张卡片 */
	.items-editor { border: none; border-radius: 0; background: transparent; overflow: visible; }
	.items-head { display: none; }
	.item-row { grid-template-columns: 1fr 1fr; gap: 10px 12px; padding: 14px; margin: 0 0 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
	.it-desc { grid-column: 1 / -1; }
	.it-qty { grid-column: 1; }
	.it-price { grid-column: 2; }
	.it-no { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 8px; text-align: left; padding-top: 0; }
	.it-amt { grid-column: 1 / -1; text-align: left; padding-top: 0; }
	.it-act { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; padding-top: 0; }
	.customer-summary .cs-grid { grid-template-columns: 1fr; }
	.item-row .it-col::before { content: attr(data-label); display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; font-weight: 600; }
	.item-row .it-act::before { margin-bottom: 0; }
	.items-summary { display: flex; align-items: baseline; justify-content: space-between; padding: 14px 16px; }
	.items-summary-label { grid-column: auto; }
	.items-summary-value { grid-column: auto; font-size: 20px; }
}

/* ---------- 客户搜索选择（combobox：输入即搜索 + 点选） ---------- */
.combo { position: relative; }
.combo-input { width: 100%; }
.combo-list { position: absolute; z-index: 40; top: calc(100% + 4px); left: 0; right: 0; max-height: 280px; overflow-y: auto; padding: 4px; background: #fff; border: 1px solid var(--border); border-radius: 9px; box-shadow: 0 12px 28px rgba(20, 30, 50, 0.14); }
.combo-item { display: block; width: 100%; padding: 10px; border-radius: 6px; background: transparent; color: var(--text); font-size: 14px; font-weight: 400; text-align: left; cursor: pointer; }
.combo-item:hover { background: var(--accent); }
.combo-empty { padding: 10px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- 已选客户资料卡 ---------- */
.customer-summary { margin-top: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: #f8fafc; }
.customer-summary:empty { display: none; }
.customer-summary .cs-name { font-weight: 600; color: var(--text); margin-bottom: 8px; }
.customer-summary .cs-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 20px; }
.customer-summary .cs-item { display: flex; gap: 8px; font-size: 13px; line-height: 1.5; }
.customer-summary .cs-label { flex: 0 0 62px; color: var(--muted); }
.customer-summary .cs-value { flex: 1 1 auto; color: var(--text); word-break: break-word; }
