/* BFLO ERP */
:root {
	--bg: #f6f4f1;
	--panel: #ffffff;
	--ink: #1f1a17;
	--muted: #6f6660;
	--line: #e6e0da;
	--accent: #7a1f2b;
	--accent-ink: #ffffff;
	--accent-soft: #f5e8ea;
	--ok: #1f7a4d;
	--ok-soft: #e6f4ec;
	--warn: #b4540a;
	--warn-soft: #fdf0e3;
	--err: #b42318;
	--err-soft: #fdecea;
	--info-soft: #eef3fb;
	--radius: 10px;
	--shadow: 0 1px 2px rgba(30, 20, 15, .05), 0 2px 8px rgba(30, 20, 15, .04);
	--nav-w: 212px;
	--top-h: 56px;
	color-scheme: light;
}
@media (prefers-color-scheme: dark) {
	:root {
		--bg: #161312;
		--panel: #201c1a;
		--ink: #efe9e4;
		--muted: #a79d96;
		--line: #342e2b;
		--accent: #d0707c;
		--accent-ink: #1a0f10;
		--accent-soft: #3a2427;
		--ok: #5fc493;
		--ok-soft: #1d3228;
		--warn: #f0a55a;
		--warn-soft: #3a2a1a;
		--err: #f2877d;
		--err-soft: #3b1f1c;
		--info-soft: #1f2733;
		--shadow: none;
		color-scheme: dark;
	}
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0;
	background: var(--bg);
	color: var(--ink);
	font: 15px/1.55 -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Segoe UI", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.35rem; margin: 0; font-weight: 650; }
h1 small { font-size: .85rem; color: var(--muted); font-weight: 400; margin-left: 6px; }
h2 { font-size: 1.02rem; margin: 0 0 12px; font-weight: 650; }
h3 { font-size: .95rem; margin: 20px 0 8px; }
code { font-size: .85em; background: var(--bg); padding: 1px 5px; border-radius: 4px; }
.bflo-muted { color: var(--muted); font-size: .9rem; }
.is-warn { color: var(--warn) !important; font-weight: 600; }
.is-neg { color: var(--err); }
.is-pos { color: var(--ok); }

/* ---------- 框架 ---------- */
.bflo-top {
	position: fixed; inset: 0 0 auto 0; height: var(--top-h); z-index: 20;
	display: flex; align-items: center; gap: 12px; padding: 0 16px;
	background: var(--panel); border-bottom: 1px solid var(--line);
}
.bflo-top__brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); }
.bflo-top__brand:hover { text-decoration: none; }
.bflo-top__user { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.bflo-top__user a:first-child { color: var(--ink); display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.bflo-top__user small { color: var(--muted); font-size: .75rem; }
.bflo-logo {
	width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-ink);
	display: inline-grid; place-items: center; font-weight: 800; font-family: Georgia, serif; flex: none;
}
.bflo-menu-btn { display: none; border: 0; background: none; font-size: 1.3rem; color: var(--ink); cursor: pointer; padding: 4px 8px; }
.bflo-nav {
	position: fixed; top: var(--top-h); bottom: 0; left: 0; width: var(--nav-w); overflow-y: auto;
	padding: 14px 10px 40px; background: var(--panel); border-right: 1px solid var(--line); z-index: 15;
}
.bflo-nav a {
	display: flex; align-items: center; justify-content: space-between;
	padding: 8px 12px; border-radius: 8px; color: var(--ink); margin: 1px 0;
}
.bflo-nav a:hover { background: var(--bg); text-decoration: none; }
.bflo-nav a.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.bflo-nav__group { font-size: .74rem; color: var(--muted); letter-spacing: .08em; margin: 16px 12px 4px; }
.bflo-main { margin-left: var(--nav-w); padding: calc(var(--top-h) + 24px) 28px 60px; max-width: calc(1280px + var(--nav-w)); }
.bflo-print .bflo-main { margin: 0 auto; padding: 24px; }

.bflo-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 18px; }
.bflo-head h1 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bflo-head__actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 元件 ---------- */
.bflo-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.bflo-card--flush { padding: 0; overflow: hidden; }
.bflo-card__title { padding: 16px 16px 0; }
.bflo-small-link { font-size: .8rem; font-weight: 400; margin-left: 8px; }
.bflo-scroll { overflow-x: auto; }
.bflo-grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 18px; align-items: start; }
.bflo-grid2 > .bflo-card { margin-bottom: 0; }
.bflo-grid2 + * { margin-top: 18px; }

.bflo-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.bflo-kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow); }
.bflo-kpi span { color: var(--muted); font-size: .82rem; }
.bflo-kpi strong { font-size: 1.45rem; font-variant-numeric: tabular-nums; font-weight: 700; }
.bflo-kpi small { color: var(--muted); font-size: .8rem; }

.bflo-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	height: 38px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--line);
	background: var(--panel); color: var(--ink); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
}
.bflo-btn:hover { border-color: var(--muted); text-decoration: none; }
.bflo-btn:disabled { opacity: .55; cursor: wait; }
.bflo-btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.bflo-btn--primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.bflo-btn--danger { color: var(--err); border-color: var(--err-soft); background: var(--err-soft); }
.bflo-btn--ghost { background: transparent; }
.bflo-btn--sm { height: 30px; padding: 0 10px; font-size: .85rem; }
.bflo-btn--block { width: 100%; height: 46px; font-size: 1rem; }
.bflo-x { border: 0; background: none; color: var(--muted); font-size: 1.2rem; cursor: pointer; }
.bflo-x:hover { color: var(--err); }

.bflo-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.bflo-table th, .bflo-table td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.bflo-table thead th { font-size: .78rem; color: var(--muted); font-weight: 600; background: var(--bg); white-space: nowrap; }
.bflo-table tbody tr:hover td { background: color-mix(in srgb, var(--bg) 60%, transparent); }
.bflo-table tfoot td { border-bottom: 0; }
.bflo-table .num, .bflo-table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bflo-table input, .bflo-table select { width: 100%; }
.bflo-card > .bflo-table { margin: 0 0 12px; }
.bflo-lines td { padding: 6px 8px; }
.bflo-lines .js-hint { display: block; margin-top: 3px; font-size: .78rem; }
.bflo-gift { display: inline-flex; align-items: center; gap: 4px; font-size: .85rem; color: var(--muted); white-space: nowrap; }
.bflo-gift input { width: 18px; height: 18px; min-height: 0; }
.bflo-gift span { display: none; }
.bflo-bars .bflo-bar { display: block; height: 12px; border-radius: 3px; background: var(--accent); min-width: 2px; }

.bflo-badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .75rem; font-weight: 600; background: var(--bg); color: var(--muted); border: 1px solid var(--line); vertical-align: middle; }
.bflo-badge--confirmed, .bflo-badge--ordered, .bflo-badge--open, .bflo-badge--pending { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.bflo-badge--shipped, .bflo-badge--closed, .bflo-badge--received, .bflo-badge--paid, .bflo-badge--approved { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.bflo-badge--partial { background: var(--info-soft); color: var(--ink); border-color: transparent; }
.bflo-badge--cancelled, .bflo-badge--void, .bflo-badge--disabled { background: var(--err-soft); color: var(--err); border-color: transparent; }
.bflo-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: .72rem; font-weight: 700; }

.bflo-alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 14px; background: var(--ok-soft); color: var(--ok); font-weight: 550; }
.bflo-alert--error { background: var(--err-soft); color: var(--err); }
.bflo-alert--info { background: var(--info-soft); color: var(--ink); font-weight: 400; }
.bflo-copy { width: 100%; margin: 8px 0; font-family: ui-monospace, monospace; font-size: .85rem; }
.bflo-empty { padding: 60px 20px; text-align: center; color: var(--muted); }

/* 表單 */
.bflo-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px 16px; margin-bottom: 16px; }
.bflo-field { display: flex; flex-direction: column; gap: 5px; font-size: .85rem; color: var(--muted); }
.bflo-field--wide { grid-column: span 2; }
.bflo-field--full { grid-column: 1 / -1; }
input, select, textarea {
	font: inherit; color: var(--ink); background: var(--panel);
	border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-height: 38px; max-width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input.num { text-align: right; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset:disabled input, fieldset:disabled select, fieldset:disabled textarea { background: var(--bg); color: var(--ink); }
.bflo-check { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--ink); }
.bflo-check input { min-height: 0; width: 18px; height: 18px; }
.bflo-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.bflo-inline { display: inline; margin: 0; }
.bflo-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.bflo-filters input[type=search] { min-width: 240px; flex: 1 1 240px; max-width: 420px; }
.bflo-seg { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 14px; }
.bflo-seg a { padding: 6px 14px; border-radius: 99px; color: var(--muted); border: 1px solid transparent; font-size: .9rem; }
.bflo-seg a.is-active { background: var(--panel); border-color: var(--line); color: var(--ink); font-weight: 600; }
.bflo-seg a:hover { text-decoration: none; color: var(--ink); }
.bflo-dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0 0 16px; font-size: .92rem; }
.bflo-dl dt { color: var(--muted); }
.bflo-dl dd { margin: 0; }
.bflo-list { list-style: none; padding: 0; margin: 0; }
.bflo-list li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.bflo-list small { color: var(--muted); }
.bflo-details { margin-top: 16px; font-size: .88rem; }
.bflo-details summary { cursor: pointer; color: var(--muted); }
.bflo-details table { margin-top: 8px; }
.bflo-pager { display: flex; gap: 4px; flex-wrap: wrap; }
.bflo-pager a, .bflo-pager span { padding: 4px 11px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); font-size: .85rem; }
.bflo-pager .is-current { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ---------- 登入頁 ---------- */
.bflo-auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
	background: radial-gradient(1200px 600px at 20% -10%, var(--accent-soft), transparent 60%), var(--bg); }
.bflo-auth__card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 32px 28px; box-shadow: 0 10px 40px rgba(30, 20, 15, .08); }
.bflo-auth__brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.bflo-auth__brand .bflo-logo { width: 42px; height: 42px; font-size: 1.3rem; border-radius: 11px; }
.bflo-auth__brand strong { display: block; font-size: 1.1rem; }
.bflo-auth__brand small { color: var(--muted); }
.bflo-auth h1 { font-size: 1.25rem; margin-bottom: 8px; }
.bflo-auth .bflo-field { margin: 16px 0; }
.bflo-auth .bflo-field input { height: 46px; font-size: 1rem; }
.bflo-tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border-radius: 10px; padding: 4px; margin-bottom: 18px; }
.bflo-tab { border: 0; background: none; padding: 9px; border-radius: 8px; font: inherit; color: var(--muted); cursor: pointer; }
.bflo-tab.is-active { background: var(--panel); color: var(--ink); font-weight: 650; box-shadow: var(--shadow); }
.bflo-msg { min-height: 1.4em; margin: 14px 0 0; font-size: .9rem; text-align: center; color: var(--muted); }
.bflo-msg.is-error { color: var(--err); }
.bflo-msg.is-ok { color: var(--ok); }

/* ---------- 列印單據 ---------- */
.bflo-doc { max-width: 820px; margin: 0 auto; background: var(--panel); padding: 32px; border: 1px solid var(--line); border-radius: var(--radius); }
.bflo-doc__head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--ink); padding-bottom: 12px; margin-bottom: 16px; }
.bflo-doc__head h1 { font-size: 1.3rem; }
.bflo-doc__head p { margin: 4px 0 0; font-size: .85rem; color: var(--muted); }
.bflo-doc__title { font-size: 1.5rem; font-weight: 700; text-align: right; letter-spacing: .2em; }
.bflo-doc__title small { font-size: .85rem; letter-spacing: 0; font-weight: 400; }
.bflo-doc__meta { width: 100%; border-collapse: collapse; margin-bottom: 16px; font-size: .9rem; }
.bflo-doc__meta th { text-align: left; color: var(--muted); font-weight: 500; width: 90px; padding: 4px 0; }
.bflo-doc__meta td { padding: 4px 12px 4px 0; }
.bflo-doc__sign { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin-top: 48px; }
.bflo-doc__sign div { border-top: 1px solid var(--ink); padding-top: 6px; text-align: center; font-size: .85rem; color: var(--muted); }
@media print {
	:root { --bg: #fff; --panel: #fff; --ink: #000; --muted: #444; --line: #bbb; }
	.bflo-noprint, .bflo-top, .bflo-nav, .bflo-seg, .bflo-filters { display: none !important; }
	.bflo-main { margin: 0; padding: 0; }
	.bflo-doc { border: 0; padding: 0; }
	body { font-size: 12px; }
}

/* ---------- 手機 ---------- */
@media (max-width: 900px) {
	.bflo-menu-btn { display: block; }
	.bflo-nav { transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 30px rgba(0, 0, 0, .15); }
	.nav-open .bflo-nav { transform: none; }
	.bflo-main { margin-left: 0; padding: calc(var(--top-h) + 16px) 16px 60px; }
	.bflo-grid2 { grid-template-columns: 1fr; }
	.bflo-field--wide { grid-column: 1 / -1; }
	.bflo-head__actions { margin-left: 0; width: 100%; }
	.bflo-kpis { grid-template-columns: 1fr 1fr; }
	.bflo-kpi strong { font-size: 1.2rem; }
	.bflo-lines, .bflo-lines tbody, .bflo-lines tfoot { display: block; width: 100%; }
	.bflo-lines thead { display: none; }
	.bflo-lines tbody tr { display: grid; grid-template-columns: 1fr 1fr auto auto; align-items: center; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line); }
	.bflo-lines tbody td { border: 0; padding: 0; }
	.bflo-lines tbody td:first-child { grid-column: 1 / -1; }
	.bflo-lines tbody td.js-amount { display: none; }
	.bflo-lines tfoot tr { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
	.bflo-lines tfoot td { border: 0; }
	.bflo-lines tfoot td:empty { display: none; }
	.bflo-lines tfoot input { width: 120px; }
	.bflo-gift span { display: inline; }
	.bflo-filters input[type=search] { min-width: 0; }
	.bflo-top__user a:first-child { display: none; }
}

/* 出貨進度 */
.bflo-progress { display: inline-block; width: 70px; height: 6px; border-radius: 3px; background: var(--line); vertical-align: middle; overflow: hidden; margin-right: 6px; }
.bflo-progress > span { display: block; height: 100%; background: var(--ok); }
.bflo-ship-pick td { vertical-align: middle; }
.bflo-ship-pick input[type=number] { width: 100px; }
.bflo-ship-pick tr.is-off td { opacity: .45; }
.bflo-ship-pick tr.is-done td { opacity: .45; }

/* ---------- 出貨單（列印，依布法羅原格式） ---------- */
.bflo-ship { max-width: 820px; margin: 0 auto; background: #fff; color: #000; padding: 24px; font-size: 13px; line-height: 1.5; border: 1px solid var(--line); border-radius: var(--radius); }
.bflo-ship p { margin: 0; }
.bflo-ship__top { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.bflo-ship__title { border: 1px solid #999; padding: 2px 6px; font-size: 20px; font-weight: 700; text-decoration: underline; }
.bflo-ship__page { border: 1px solid #ccc; padding: 6px 8px; font-size: 11px; min-width: 80px; }
.bflo-ship__company { border: 1px solid #ccc; padding: 4px 8px; font-size: 18px; font-weight: 700; }
.bflo-ship__ids { margin-left: auto; border: 1px solid #999; padding: 3px 8px; font-size: 12px; }
.bflo-ship__info { display: grid; grid-template-columns: 58% 42%; border: 1px solid #999; margin-bottom: 6px; }
.bflo-ship__info > div { padding: 4px 8px; }
.bflo-ship__info > div + div { border-left: 1px solid #999; }
.bflo-ship__lines { width: 100%; border-collapse: collapse; }
.bflo-ship__lines th, .bflo-ship__lines td { border: 1px solid #999; padding: 3px 6px; }
.bflo-ship__lines thead th, .bflo-ship__lines tfoot th { background: #f4f4f4; font-weight: 700; text-align: center; }
.bflo-ship__lines thead th:first-child { width: 58%; }
.bflo-ship__lines .c { text-align: center; }
.bflo-ship__lines .r { text-align: right; font-variant-numeric: tabular-nums; }
.bflo-ship__lines tfoot th.r { text-align: right; }
.bflo-ship__meta { margin-top: 8px !important; font-size: 11px; color: #666; }
@media print { .bflo-ship { border: 0; padding: 0; max-width: none; } }
@media (prefers-color-scheme: dark) { .bflo-ship { color: #000; } }

.bflo-selsearch { display: block; width: 100%; margin-bottom: 4px; min-height: 32px; padding: 5px 10px; font-size: .85rem; background: var(--bg); }

.bflo-newprod { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; margin-top: 6px; padding: 8px; border: 1px dashed var(--accent); border-radius: 8px; background: var(--accent-soft); }
.bflo-newprod[hidden] { display: none; }
.bflo-newprod input, .bflo-newprod select { min-height: 32px; padding: 5px 8px; font-size: .85rem; }

/* ---------- 英文國外採購單（列印） ---------- */
.bflo-po { max-width: 820px; margin: 0 auto; background: #fff; color: #000; padding: 40px 48px; font: 14px/1.45 Calibri, Carlito, "Segoe UI", Arial, sans-serif; border: 1px solid var(--line); border-radius: var(--radius); }
.bflo-po p { margin: 0; }
.bflo-po a { color: #1a4fd6; }
.bflo-po__logo { width: 130px; display: block; margin: 0 0 36px 20px; }
.bflo-po__grid { display: grid; grid-template-columns: 60% 40%; row-gap: 24px; margin-bottom: 24px; }
.bflo-po__sup { font-family: Georgia, "Times New Roman", serif; font-size: 16px; }
.bflo-po__lines { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
.bflo-po__lines th { font-weight: 700; text-align: center; border-bottom: 1px solid #000; padding: 3px 6px; }
.bflo-po__lines td { padding: 3px 6px; text-align: center; }
.bflo-po__lines tbody tr:last-child td { padding-bottom: 36px; border-bottom: 1px solid #000; }
.bflo-po__lines .r { text-align: right; }
.bflo-po__lines tfoot th, .bflo-po__lines tfoot td { border: 0; padding-top: 6px; }
.bflo-po__foot { display: grid; grid-template-columns: 60% 40%; align-items: end; border-bottom: 1px solid #000; padding-bottom: 36px; }
.bflo-po__sign { border-top: 1px solid #000; text-align: right; padding-top: 4px; margin-top: 60px; }
@media print { .bflo-po { border: 0; padding: 0; max-width: none; } }

/* ---------- 報表 ---------- */
.bflo-seg--tabs { border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.bflo-rfilter { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.bflo-quick { font-size: .85rem; color: var(--muted); margin-left: auto; }
.bflo-quick a { margin-left: 6px; }
.bflo-rinfo { margin: -4px 0 14px; font-size: .82rem; }
.bflo-rt__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 10px; }
.bflo-rt__head h2 { margin: 0; }
.bflo-rt__note { padding: 0 16px 10px; margin: 0; }
.bflo-rt__more { padding: 10px 16px; margin: 0; font-size: .88rem; }
.bflo-sortable thead th { cursor: pointer; user-select: none; }
.bflo-sortable thead th:hover { color: var(--ink); }
.bflo-sortable thead th[data-dir="desc"]::after { content: ' ▼'; font-size: .7em; }
.bflo-sortable thead th[data-dir="asc"]::after { content: ' ▲'; font-size: .7em; }
.bflo-sortable tfoot th { background: var(--bg); font-weight: 700; border-top: 2px solid var(--line); }
.bflo-sortable tfoot th.num { text-align: right; }
.bflo-kpi small .is-pos, .bflo-kpi small .is-neg { font-weight: 600; }
@media (max-width: 900px) { .bflo-quick { margin-left: 0; width: 100%; } }
.bflo-rt td, .bflo-rt th { white-space: nowrap; }
.bflo-rt td:first-child { white-space: normal; min-width: 180px; }

/* ---------- 手機：表格維持電腦版欄位，左右滑動 ---------- */
.bflo-card > .bflo-scroll { margin: 0 0 12px; }
.bflo-scroll { -webkit-overflow-scrolling: touch; }
@media (max-width: 900px) {
	.bflo-scroll > .bflo-table { min-width: var(--minw, 0); }
	.bflo-scroll { margin-left: -4px; margin-right: -4px; }
}
.bflo-nav__mode { margin-top: 18px !important; border-top: 1px solid var(--line); border-radius: 0 !important; padding-top: 14px !important; color: var(--muted) !important; font-size: .88rem; }

/* 單據頁（?print=1）在手機上以 A4 寬度排版後縮放，按鈕放大方便點 */
@media (pointer: coarse) {
	.bflo-print .bflo-noprint .bflo-btn { height: 64px; padding: 0 32px; font-size: 1.5rem; }
}

/* ---------- 單一客戶報表 ---------- */
.bflo-cpick { display: inline-flex; flex-direction: column; min-width: 280px; }
.bflo-cpick .bflo-selsearch { margin-bottom: 4px; }
.bflo-client__head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.bflo-client__links { display: flex; gap: 6px; flex-wrap: wrap; align-items: flex-start; }
.bflo-client__dl { grid-template-columns: max-content 1fr max-content 1fr; margin: 0; }
@media (max-width: 900px) {
	.bflo-client__dl { grid-template-columns: max-content 1fr; }
	.bflo-cpick { min-width: 0; width: 100%; }
}
.bflo-cpick > * { flex: none !important; width: 100%; }

/* ---------- 刪除／作廢／垃圾桶 ---------- */
.bflo-alert--warn { background: var(--warn-soft); color: var(--warn); }
.bflo-badge--deleted, .bflo-badge--voided { background: var(--err-soft); color: var(--err); border-color: transparent; }
.bflo-trash-note { border-color: var(--err); background: var(--err-soft); }
.bflo-trash-note h2 { color: var(--err); margin-top: 0; }
.bflo-danger-zone { margin: 0 0 18px; border: 1px dashed var(--line); border-radius: var(--radius); padding: 10px 14px; background: var(--panel); }
.bflo-danger-zone summary { cursor: pointer; color: var(--err); font-weight: 600; }
.bflo-danger-zone[open] { border-color: var(--err); }
.bflo-rev summary { cursor: pointer; color: var(--err); font-size: .85rem; white-space: nowrap; }
.bflo-rev form { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; min-width: 220px; }
tr.is-voided td { color: var(--muted); }
tr.is-voided td.num { text-decoration: line-through; }

/* 一鍵已收款 */
.bflo-quickpay { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 14px; }
.bflo-quickpay select, .bflo-quickpay input[type=date] { width: auto; }
.bflo-quickpay--bulk { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.bflo-quickpay[hidden] { display: none; }
.bflo-partial { margin-top: 6px; }
.bflo-partial summary { cursor: pointer; color: var(--accent); font-weight: 600; margin-bottom: 8px; }
.bflo-table td .bflo-inline + .bflo-btn { margin-left: 4px; }
.bflo-paycell { white-space: nowrap; }
.bflo-artable td, .bflo-artable th { white-space: nowrap; }

/* 對帳單：一次列印多位客戶，每位一頁 */
.bflo-statement + .bflo-statement { margin-top: 24px; }
@media print { .bflo-statement { break-after: page; page-break-after: always; } .bflo-statement:last-of-type { break-after: auto; page-break-after: auto; } }
.bflo-po__note { color: #444; font-style: italic; }

.bflo-quickpay--bulk { display: block; }
.bflo-quickpay__head { margin-bottom: 8px; }
.bflo-quickpay--bulk .bflo-fields { margin-bottom: 0; }
.bflo-payform { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.bflo-attach { white-space: nowrap; font-size: .85rem; }

/* 明細：每列先選廠商再選商品 */
.bflo-pcell { display: grid; grid-template-columns: minmax(120px, 190px) 1fr; gap: 6px; align-items: start; }
.bflo-pcell > select.js-product, .bflo-pcell > .js-hint, .bflo-pcell > .bflo-newprod { grid-column: 1 / -1; }
.bflo-pcell > .bflo-selsearch { margin-bottom: 0; }
.bflo-pcell > .js-row-brand { min-height: 32px; padding: 5px 8px; font-size: .85rem; }
@media (max-width: 900px) { .bflo-pcell { grid-template-columns: 1fr; } }

/* 買家類型與批次售價 */
.bflo-btrow { display: flex !important; gap: 8px; align-items: center; flex-wrap: wrap; }
.bflo-btrow input[name=name] { width: 180px; }
.bflo-pricegrid input[type=number] { width: 110px; text-align: right; }
.bflo-pricegrid td, .bflo-pricegrid th { white-space: nowrap; }
.bflo-pricebulk .bflo-filters { margin-bottom: 0; }

.bflo-sortth a { color: inherit; text-decoration: none; white-space: nowrap; }
.bflo-sortth a:hover { color: var(--ink); }
.bflo-sortth.is-sorted a { color: var(--accent); }

/* ---------- 拜訪打卡 ---------- */
.bflo-badge--warn { background: var(--err-soft); color: var(--err); border-color: transparent; }
.bflo-badge--ok, .bflo-badge--done { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.bflo-note { white-space: normal; background: var(--bg); border-radius: 8px; padding: 10px 12px; margin: 6px 0; line-height: 1.6; }
.bflo-table--compact { max-width: 560px; margin-bottom: 16px; }
.bflo-clip { max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
tr.is-late td, .bflo-task.is-late { background: var(--err-soft); }
.bflo-geo { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; background: var(--warn-soft); font-weight: 600; }
.bflo-geo[data-state="ok"] { background: var(--ok-soft); color: var(--ok); }
.bflo-geo[data-state="err"] { background: var(--err-soft); color: var(--err); }
.bflo-photo-preview, .bflo-photos { display: flex; flex-wrap: wrap; gap: 8px; }
.bflo-photo-preview img, .bflo-photos img { width: 110px; height: 110px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.bflo-tasklist { display: grid; gap: 10px; margin-bottom: 18px; }
.bflo-task { display: flex; gap: 12px; justify-content: space-between; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--card, #fff); }
.bflo-task .bflo-btn { flex: none; }
@media (max-width: 640px) { .bflo-task { flex-direction: column; align-items: stretch; } .bflo-photo-preview img, .bflo-photos img { width: 30vw; height: 30vw; } }
.bflo-einv { margin-top: 16px; padding-top: 12px; border-top: 1px dashed var(--line); }
.bflo-einv .bflo-inline input[name="reason"] { width: 160px; margin-right: 6px; }
.bflo-pre { white-space: pre-wrap; font-size: .8rem; background: var(--bg); padding: 8px; border-radius: 6px; max-height: 240px; overflow: auto; }

/* ---------- 觸控平板／折疊手機展開（iPhone 折疊機、iPad）：一律用手機版版面 ----------
   head.php 依「觸控裝置＋短邊 ≤ 1100」或「視窗 ≤ 900」在 <html> 加 bflo-m；可在選單切換回電腦版 */
html.bflo-m .bflo-menu-btn { display: block; }
html.bflo-m .bflo-nav { transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 30px rgba(0, 0, 0, .15); }
html.bflo-m .nav-open .bflo-nav { transform: none; }
html.bflo-m .bflo-main { margin-left: 0; padding: calc(var(--top-h) + 16px) 16px 60px; }
html.bflo-m .bflo-grid2 { grid-template-columns: 1fr; }
html.bflo-m .bflo-field--wide { grid-column: 1 / -1; }
html.bflo-m .bflo-head__actions { margin-left: 0; width: 100%; }
html.bflo-m .bflo-kpis { grid-template-columns: 1fr 1fr; }
html.bflo-m .bflo-kpi strong { font-size: 1.2rem; }
html.bflo-m .bflo-lines, html.bflo-m .bflo-lines tbody, html.bflo-m .bflo-lines tfoot { display: block; width: 100%; }
html.bflo-m .bflo-lines thead { display: none; }
html.bflo-m .bflo-lines tbody tr { display: grid; grid-template-columns: 1fr 1fr auto auto; align-items: center; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line); }
html.bflo-m .bflo-lines tbody td { border: 0; padding: 0; }
html.bflo-m .bflo-lines tbody td:first-child { grid-column: 1 / -1; }
html.bflo-m .bflo-lines tbody td.js-amount { display: none; }
html.bflo-m .bflo-lines tfoot tr { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
html.bflo-m .bflo-lines tfoot td { border: 0; }
html.bflo-m .bflo-lines tfoot td:empty { display: none; }
html.bflo-m .bflo-lines tfoot input { width: 120px; }
html.bflo-m .bflo-gift span { display: inline; }
html.bflo-m .bflo-filters input[type=search] { min-width: 0; }
html.bflo-m .bflo-top__user a:first-child { display: none; }
html.bflo-m .bflo-quick { margin-left: 0; width: 100%; }
html.bflo-m .bflo-scroll > .bflo-table { min-width: var(--minw, 0); }
html.bflo-m .bflo-scroll { margin-left: -4px; margin-right: -4px; }
html.bflo-m .bflo-client__dl { grid-template-columns: max-content 1fr; }
html.bflo-m .bflo-cpick { min-width: 0; width: 100%; }
html.bflo-m .bflo-pcell { grid-template-columns: 1fr; }
html.bflo-m body { font-size: 16px; }
html.bflo-m input, html.bflo-m select, html.bflo-m textarea { font-size: 16px; min-height: 44px; }
html.bflo-m textarea { min-height: 88px; }
html.bflo-m .bflo-btn { min-height: 44px; }
html.bflo-m .bflo-btn--sm { min-height: 36px; }
html.bflo-m .bflo-nav a { padding-top: 11px; padding-bottom: 11px; }
html.bflo-m .bflo-fields { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
@media (min-width: 901px) {
	html.bflo-m .bflo-pcell { grid-template-columns: minmax(140px, 220px) 1fr; }
	html.bflo-m .bflo-kpis { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
	html.bflo-m .bflo-nav { width: 300px; }
}
html.bflo-m .bflo-pcell > .js-row-brand, html.bflo-m .bflo-selsearch { min-height: 44px; font-size: 16px; }
.bflo-logdetail { min-width: 260px; line-height: 1.7; }
.bflo-logdetail b { font-weight: 600; color: var(--muted); }
.bflo-logsep { color: var(--line); margin: 0 4px; }
.bflo-nowrap { white-space: nowrap; }

/* ---------- 上班打卡 ---------- */
.bflo-punch { text-align: center; max-width: 560px; margin: 0 auto 18px; }
.bflo-punch__clock { font-size: 3rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .02em; line-height: 1.1; }
.bflo-punch__date { color: var(--muted); margin: 6px 0 14px; }
.bflo-punch__status { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.bflo-punch__status > div { background: var(--bg); border-radius: 10px; padding: 10px; }
.bflo-punch__status small { display: block; color: var(--muted); }
.bflo-punch__status strong { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.bflo-punch__btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 10px; }
.bflo-punch__btn { height: 64px !important; font-size: 1.15rem !important; font-weight: 700; justify-content: center; }
.bflo-punch__note { width: 100%; }
.bflo-punch .bflo-geo { text-align: left; }
.bflo-punchlog > div { white-space: nowrap; font-size: .88rem; }
.bflo-linkbtn { background: none; border: 0; padding: 0 4px; color: var(--err); cursor: pointer; font-size: .8rem; }
.bflo-checks { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin-bottom: 14px; }
.bflo-loctable input { width: 100%; min-width: 110px; }
.bflo-loctable td:first-child input { min-width: 160px; }
.bflo-geoform { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.bflo-geoform input[name="maps_link"] { flex: 1 1 260px; min-width: 200px; }
.bflo-golive { border-color: var(--err); }
.bflo-golive h2 { color: var(--err); }
.bflo-golive__list { display: grid; gap: 8px; margin: 12px 0; }
.bflo-histtable td { vertical-align: top; }
.bflo-histlines { margin: 4px 0 0; padding-left: 18px; font-size: .85rem; }
tr.bflo-histpay td { color: var(--muted); }

/* ---------- 回饋 ---------- */
.js-rebate-line { display: block; font-size: .75rem; text-align: right; }
.bflo-rebate-row td { color: var(--accent); }
.js-price[readonly] { background: var(--bg); color: var(--muted); }
@media (max-width: 900px) { .bflo-lines tbody td.js-rebate-cell { grid-column: 1 / -1; } .bflo-lines tbody td.js-rebate-cell input { width: 100%; } }
html.bflo-m .bflo-lines tbody td.js-rebate-cell { grid-column: 1 / -1; }
@media (max-width: 900px) { .bflo-lines tbody td.js-rebate-cell::before { content: '回饋／瓶'; display: block; font-size: .78rem; color: var(--muted); margin-bottom: 2px; } }
html.bflo-m .bflo-lines tbody td.js-rebate-cell::before { content: '回饋／瓶'; display: block; font-size: .78rem; color: var(--muted); margin-bottom: 2px; }
.js-rebate.is-over { border-color: var(--err); color: var(--err); }

/* ---------- 年度合約書 ---------- */
.bflo-contract { max-width: 820px; margin: 0 auto; background: #fff; color: #111; padding: 32px 40px; font-size: 13.5px; line-height: 1.6; }
.bflo-contract__head { display: grid; grid-template-columns: 180px 1fr; align-items: center; gap: 12px; margin-bottom: 18px; }
.bflo-contract__brand { font-size: 13px; color: #333; }
.bflo-contract__logo { max-width: 140px; max-height: 70px; display: block; margin-bottom: 4px; }
.bflo-contract__title { font-size: 22px; margin: 0; text-align: center; color: #111; }
.bflo-contract__draft { text-align: center; color: #b4232a; font-weight: 700; margin: 0 0 8px; }
.bflo-contract__info { border-collapse: collapse; margin: 0 0 14px 20px; }
.bflo-contract__info th { font-weight: 400; padding: 2px 8px 2px 0; text-align: left; }
.bflo-contract__info td { padding: 2px 6px; }
.bflo-contract__info td.u { border-bottom: 1px solid #111; min-width: 160px; text-align: center; }
.bflo-contract__table { width: 100%; border-collapse: collapse; margin: 6px 0 16px; }
.bflo-contract__table th, .bflo-contract__table td { border: 1px solid #333; padding: 6px 8px; vertical-align: middle; }
.bflo-contract__table thead th { background: #f2f2f2; font-weight: 700; }
.bflo-contract__table .r { text-align: right; font-variant-numeric: tabular-nums; }
.bflo-contract__table .c { text-align: center; font-size: 15px; }
.bflo-contract__table small { color: #666; }
.bflo-contract__sum th { background: #f7efe9; font-size: 15px; }
.bflo-contract__note { white-space: normal; min-height: 40px; }
.bflo-contract__sec { margin: 10px 0; }
.bflo-contract__sec ol { margin: 4px 0 0; padding-left: 22px; }
.bflo-contract__sign { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 36px; text-align: center; }
.bflo-contract__stamp { height: 90px; border-bottom: 1px solid #111; }
.bflo-contract__sign p { margin: 6px 0 0; }
.bflo-contract__date { text-align: center; margin-top: 24px; letter-spacing: .1em; }
.bflo-contractbox { margin: 12px 0; border: 1px dashed var(--line); border-radius: var(--radius); padding: 10px 14px; }
.bflo-contractbox summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.js-coop { margin-top: 4px; font-size: .8rem; width: 100%; }
@media print { .bflo-contract { padding: 0; } }
.bflo-contract__table thead th { white-space: nowrap; }
.bflo-ctpick { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; margin: 0 0 14px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: var(--radius); }
.bflo-ctpick[hidden] { display: none; }
.bflo-ctpick .bflo-field { min-width: 280px; margin: 0; }
.bflo-ctpick .js-ct-info { flex-basis: 100%; }
tr.is-contract td { background: var(--accent-soft); }

/* 寄賣 */
.bflo-seg--radio label { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 99px; border: 1px solid var(--line); cursor: pointer; font-size: .92rem; }
.bflo-seg--radio label:has(input:checked) { border-color: var(--ink); background: var(--panel); font-weight: 600; }
.bflo-table tr.is-muted td { color: var(--muted); }
.bflo-cs-tip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 14px; padding: 10px 14px; border-radius: var(--radius); background: var(--warn-soft, #fff6e0); border: 1px solid var(--warn, #e6b54a); font-size: .92rem; line-height: 1.5; }

/* 出貨單：點陣印表機連續報表紙（EPSON LQ-310） */
.bflo-lq-bar { max-width: 960px; margin: 0 auto 16px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.bflo-lq { box-sizing: border-box; width: var(--lqw); height: var(--lqh); padding: var(--lqt) var(--lqr) 0 var(--lql); margin: 0 auto 18px; overflow: hidden; background: #fff; color: #000; line-height: 1.32; font-family: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", sans-serif; position: relative;
	/* 螢幕預覽：畫出兩側孔邊 */
	background-image: radial-gradient(circle at 50% 50%, #ddd 1.9mm, transparent 2mm), radial-gradient(circle at 50% 50%, #ddd 1.9mm, transparent 2mm);
	background-size: 12.7mm 12.7mm, 12.7mm 12.7mm; background-repeat: repeat-y, repeat-y; background-position: 0 0, 100% 0;
	box-shadow: 0 1px 6px rgba(0,0,0,.2); }
.bflo-lq p { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bflo-lq__top { display: flex; align-items: center; gap: 3mm; margin-bottom: 1.5mm; }
.bflo-lq__title { font-size: 1.55em; font-weight: 700; text-decoration: underline; letter-spacing: .1em; }
.bflo-lq__page { font-size: .85em; }
.bflo-lq__company { flex: 1; text-align: center; font-size: 1.35em; font-weight: 700; }
.bflo-lq__ids { font-size: .9em; border: 1px solid #000; padding: .3mm 1.5mm; }
.bflo-lq__info { display: grid; grid-template-columns: 57% 43%; border: 1px solid #000; margin-bottom: 1.5mm; }
.bflo-lq__info > div { padding: .6mm 2mm; min-width: 0; }
.bflo-lq__info > div + div { border-left: 1px solid #000; }
.bflo-lq__lines { width: 100%; border-collapse: collapse; table-layout: fixed; }
.bflo-lq__lines th, .bflo-lq__lines td { border: 1px solid #000; padding: .3mm 1.5mm; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.bflo-lq__lines thead th, .bflo-lq__lines tfoot th { font-weight: 700; text-align: center; }
.bflo-lq__lines .r { text-align: right; font-variant-numeric: tabular-nums; }
.bflo-lq__lines .c { text-align: center; }
.bflo-lq__lines .l { text-align: left; }
.bflo-lq__foot { display: flex; justify-content: space-between; margin-top: 2mm; font-size: .9em; }
.bflo-lq__foot span:last-child { min-width: 45mm; border-bottom: 1px solid #000; padding-right: 30mm; }
@media print {
	.bflo-print .bflo-main { padding: 0 !important; max-width: none; }
	.bflo-lq { margin: 0; box-shadow: none; background: #fff !important; background-image: none !important; break-after: page; page-break-after: always; }
	.bflo-lq:last-of-type { break-after: auto; page-break-after: auto; }
}
@media (prefers-color-scheme: dark) { .bflo-lq { color: #000; } }
.bflo-selbar { position: sticky; bottom: 12px; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 12px 0; padding: 10px 14px; background: var(--panel); border: 1px solid var(--accent); border-radius: var(--radius); box-shadow: 0 4px 18px rgba(0,0,0,.12); }
.bflo-table tr.is-picked td { background: var(--accent-soft); }
.bflo-lq--a { margin-bottom: 0; }
.bflo-lq--b { padding-top: 2mm; border-top: 1px dashed #bbb; }
@media print { .bflo-lq--b { border-top: 0; } }
.bflo-lq__lines td { height: 1.45em; }
