:root { --p: #1a73e8; --bg: #f3f5f8; --card: #fff; --line: #dde3ea; --text: #1d2a36; --muted: #6b7a89; --ok: #1b6b2a; --warn: #b36b00; --err: #c62828; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 -apple-system, "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif; }
.top { position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top)); background: var(--p); color: #fff; }
.brand { font-weight: bold; }
.top .muted { color: #dbe7ff; font-size: 12px; }
.link { background: none; border: 0; color: #fff; text-decoration: underline; font: inherit; margin-left: 10px; }
.view { padding: 12px; max-width: 760px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.card.narrow { max-width: 380px; margin: 40px auto; }
label { display: block; margin: 8px 0; font-size: 14px; color: #345; }
input, select, button { font: inherit; }
input:not([type=radio]):not([type=checkbox]), select { width: 100%; padding: 10px 12px; border: 1px solid #b7c2cf; border-radius: 8px; background: #fff; font-size: 16px; }
label > input, label > select { margin-top: 4px; }
button { padding: 10px 14px; border-radius: 8px; border: 1px solid #b7c2cf; background: #fff; cursor: pointer; }
button.primary { background: var(--p); border-color: var(--p); color: #fff; font-weight: bold; }
button.danger { color: var(--err); border-color: var(--err); }
button.big { width: 100%; padding: 12px; font-size: 17px; margin-top: 8px; }
button.icon { padding: 10px 12px; font-size: 18px; }
button.small { padding: 4px 8px; font-size: 13px; }
.msg { min-height: 20px; font-size: 14px; margin-top: 6px; }
.msg.err { color: var(--err); } .msg.ok { color: var(--ok); }
.muted { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 120px; }
.row > button { flex: 0 0 auto; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs button { flex: 1; padding: 10px 4px; border-radius: 8px; background: #fff; }
.tabs button.active { background: var(--p); color: #fff; border-color: var(--p); }
.tab { display: none; } .tab.active { display: block; }
.scanbar { display: flex; gap: 6px; margin-bottom: 10px; }
.scanbar input { flex: 1; min-width: 0; }
.scanbar input[type=number] { flex: 0 0 72px; text-align: center; }
.item { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }
.item h3 { margin: 0 0 4px; font-size: 18px; }
.item .price { font-size: 22px; font-weight: bold; color: var(--p); }
.item .code { font-family: Consolas, monospace; color: var(--muted); }
.stocks { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; margin-top: 8px; }
.stocks div { background: #f4f7fb; border-radius: 6px; padding: 6px 8px; font-size: 13px; display: flex; justify-content: space-between; }
.stocks div.here { background: #e3f0ff; font-weight: bold; }
.stocks b.neg { color: var(--err); }
.session-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.stats { display: flex; gap: 14px; font-size: 14px; }
.stats b { font-size: 18px; } .warn { color: var(--warn); }
.last { background: #e8f5e9; border: 1px solid #c8e6c9; border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; min-height: 40px; }
.last.err { background: #fdecea; border-color: #f5c6c2; }
table.lines { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; font-size: 14px; }
table.lines th, table.lines td { padding: 8px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.lines th.num, table.lines td.num { text-align: right; white-space: nowrap; }
td .nm { font-weight: bold; } td .cd { color: var(--muted); font-size: 12px; font-family: Consolas, monospace; }
td.diff-pos { color: var(--ok); font-weight: bold; } td.diff-neg { color: var(--err); font-weight: bold; }
td input.cnt { width: 64px; padding: 4px; text-align: right; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.sess { display: flex; justify-content: space-between; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; }
.sess.closed { opacity: .7; }
.scanner { position: fixed; inset: 0; background: #000; z-index: 50; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scan-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.scan-box { width: 70vw; max-width: 360px; height: 40vw; max-height: 220px; border: 3px solid #4caf50; border-radius: 10px; box-shadow: 0 0 0 9999px rgba(0,0,0,.35); }
.scan-hint { color: #fff; margin-top: 12px; text-shadow: 0 1px 3px #000; }
.scan-close { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 12px; background: rgba(255,255,255,.9); }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40; display: flex; align-items: center; justify-content: center; padding: 12px; }
.modal-body { background: #fff; border-radius: 12px; padding: 16px; width: 100%; max-width: 480px; max-height: 90vh; overflow: auto; }
.modal-body h3 { margin: 0 0 6px; }
.preview { font-size: 13px; background: #f4f7fb; border-radius: 8px; padding: 8px 10px; margin-top: 8px; max-height: 40vh; overflow: auto; white-space: pre-wrap; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #223; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 60; max-width: 90vw; }
.toast.err { background: var(--err); } .toast.ok { background: var(--ok); }

/* hidden 屬性優先於任何 display 設定 */
[hidden] { display: none !important; }

/* 進貨／退貨：廠商搜尋 */
.vendor-pick { position: relative; flex: 2; min-width: 200px; }
.vendor-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 20; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.15); max-height: 260px; overflow: auto; }
.vendor-list div { padding: 10px 12px; border-bottom: 1px solid #eef2f6; cursor: pointer; }
.vendor-list div:hover { background: #eef5ff; }
.doc-vendor-sel { margin-top: 6px; }
.doc-vendor-sel.ok { color: var(--ok); font-weight: bold; font-size: 15px; }
.docs .doc { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; }
.docs .doc b.no { font-family: Consolas, monospace; font-size: 16px; }
@media (max-width: 480px) { .tabs button { padding: 10px 2px; font-size: 13px; } .stats { gap: 10px; font-size: 13px; } }
