/* 行員端（臨櫃核銷）版面：側欄＋頂列＋內容；iPad 側欄可收合，iPhone 側欄改抽屜、表格改卡片。 */
.t-layout { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; transition: grid-template-columns .22s ease; }
.t-layout.collapsed { grid-template-columns: 76px minmax(0, 1fr); }

/* 讓 sticky 側欄與頂列在捲動時維持固定（overflow:hidden 會讓 body 變成捲動容器） */
html, body { overflow-x: clip; }

/* ---------- 側欄 ---------- */
.t-side { position: sticky; top: 0; height: 100vh; height: 100dvh; background: var(--side-bg); border-right: 1px solid var(--side-line); display: flex; flex-direction: column; padding: calc(var(--safe-t) + 14px) 14px calc(var(--safe-b) + 12px) calc(var(--safe-l) + 14px); overflow: hidden; z-index: 30; }
.side-logo { height: 48px; display: flex; align-items: center; padding: 0 4px; margin-bottom: 18px; }
.side-logo .full { height: 38px; width: auto; }
.side-logo .mark { height: 40px; width: 40px; display: none; }
.side-group { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--ink-3); padding: 8px 12px; margin-top: 6px; white-space: nowrap; }
.side-item { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 46px; padding: 0 12px; border-radius: 8px; color: var(--ink-2); font-size: 16px; text-align: left; white-space: nowrap; margin-bottom: 2px; }
.side-item:hover:not(.disabled) { background: rgba(154, 0, 54, .05); }
.side-item.on { background: var(--bot-red-10); color: var(--bot-red); font-weight: 600; }
.side-item.on::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 4px; border-radius: 0 3px 3px 0; background: var(--bot-red); }
.side-item.disabled { color: var(--ink-4); cursor: not-allowed; }
.side-item em { margin-left: auto; font-style: normal; font-size: 12px; color: var(--ink-4); }
.side-item .lbl { overflow: hidden; text-overflow: ellipsis; }
.side-sep { height: 1px; background: var(--side-line); margin: 10px 4px; }
.side-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; color: var(--ink-3); font-size: 13px; padding: 0 4px 0 10px; white-space: nowrap; }
.t-layout.collapsed .side-logo .full, .t-layout.collapsed .side-item .lbl, .t-layout.collapsed .side-item em, .t-layout.collapsed .side-group span, .t-layout.collapsed .side-foot span { display: none; }
.t-layout.collapsed .side-logo { justify-content: center; padding: 0; }
.t-layout.collapsed .side-logo .mark { display: block; }
.t-layout.collapsed .side-item { justify-content: center; padding: 0; }
.t-layout.collapsed .side-group { justify-content: center; padding: 8px 0; }
.t-layout.collapsed .side-group::after { content: ""; width: 24px; height: 1px; background: var(--side-line); }
.t-layout.collapsed .side-foot { justify-content: center; padding: 0; }
.side-mask { display: none; }

/* ---------- 主區 ---------- */
.t-main { min-width: 0; display: flex; flex-direction: column; }
.t-top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; min-height: 64px; padding: calc(var(--safe-t) + 8px) calc(var(--safe-r) + 20px) 8px 24px; background: rgba(255, 255, 255, .96); border-bottom: 1px solid var(--line); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.menu-btn { display: none; }
.crumb { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--ink-2); white-space: nowrap; min-width: 0; }
.crumb b { color: var(--ink); font-weight: 600; }
.crumb .chev { color: var(--ink-4); }
.t-top .sp { flex: 1; }
.nametag { display: flex; align-items: center; gap: 10px; padding: 6px 12px 6px 6px; border: 1px solid var(--line); border-radius: 10px; background: #fff; min-height: 48px; }
.nametag .av { width: 34px; height: 34px; border-radius: 50%; background: var(--bot-red-10); color: var(--bot-red); display: grid; place-items: center; font-weight: 600; }
.nametag b { display: block; font-size: 14px; font-weight: 600; line-height: 1.3; }
.nametag small { display: block; font-size: 12px; color: var(--ink-3); line-height: 1.3; white-space: nowrap; }

.t-content { width: 100%; max-width: 1360px; margin: 0 auto; padding: 26px 32px calc(var(--safe-b) + 40px); }
.t-content h1 { margin: 0 0 14px; font-size: 30px; font-weight: 700; letter-spacing: .02em; }
.tabs-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { position: relative; min-height: 48px; padding: 0 14px; font-size: 17px; color: var(--ink-2); white-space: nowrap; }
.tabs button.on { color: var(--bot-red); font-weight: 600; }
.tabs button.on::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 3px; border-radius: 2px; background: var(--bot-red); }
.tabs-row .btn { margin-bottom: 8px; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat .k svg { color: var(--bot-red); }

.list-card { overflow: hidden; }
.card-h { display: flex; align-items: center; gap: 12px; padding: 18px 20px 14px; }
.card-h h2 { margin: 0; font-size: 19px; font-weight: 600; }
.card-h p { margin: 2px 0 0; font-size: 14px; color: var(--ink-3); }
.card-h .sp { flex: 1; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ok); white-space: nowrap; }
.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(30, 127, 79, .45); } 100% { box-shadow: 0 0 0 8px rgba(30, 127, 79, 0); } }
.tbl td { white-space: nowrap; }
.tbl .serial { font-family: var(--mono); font-size: 16px; font-weight: 600; letter-spacing: .04em; }
.tbl .act { text-align: right; }
.tbl .newcell { width: 54px; padding-right: 0; }
.tbl tr.is-new td { animation: newFlash 1.2s ease 3; background: #fffbea; }
@keyframes newFlash { 0%, 100% { background: #fffbea; } 50% { background: var(--new-bg); } }
.copy { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; color: var(--ink-2); }
.copy:hover { color: var(--bot-red); }
.empty { padding: 36px 20px 40px; text-align: center; color: var(--ink-3); font-size: 15px; }
.sim-note { margin-top: 18px; }

/* ---------- 提領憑證交易頁 ---------- */
.tx-head { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.tx-head .back { padding: 0 14px 0 8px; }
.tx-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-width: 0; }
.tx-title h1 { margin: 0 !important; font-size: 26px !important; }
.tx-title .serial { font-size: 22px; font-weight: 600; letter-spacing: .06em; color: var(--bot-red); }
.stepper { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 18px; }
.stepper span { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-3); padding-top: 10px; border-top: 3px solid var(--line); white-space: nowrap; }
.stepper span i { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: 12px; font-weight: 600; background: var(--bg-3); color: var(--ink-2); flex: none; }
.stepper span.done { border-color: var(--bot-red); color: var(--bot-red); font-weight: 500; }
.stepper span.done i { background: var(--bot-red); color: #fff; }
.stepper span.cur { border-color: var(--bot-red-20); color: var(--ink); font-weight: 600; }
.stepper span.cur i { background: var(--bot-red-10); color: var(--bot-red); }
.tx-sec { padding: 18px 20px 20px; margin-bottom: 16px; transition: opacity .2s; }
.tx-sec h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-size: 18px; font-weight: 600; }
.tx-sec h2 .no { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-3); color: var(--ink-2); font-size: 14px; font-weight: 600; }
.tx-sec.done h2 .no { background: var(--bot-red); color: #fff; }
.tx-sec.lock { opacity: .55; background: var(--bg-2); }
.tx-sec .k { display: block; font-size: 13px; color: var(--ink-3); margin-bottom: 6px; }
.kv-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px 20px; }
.kv-grid .k { margin-bottom: 2px; }
.kv-grid .v { display: block; font-size: 16px; font-weight: 500; overflow-wrap: anywhere; }
.id-grid { display: grid; grid-template-columns: 1fr 1.1fr 1.2fr; gap: 16px; }
.id-grid label { display: block; min-width: 0; }
.id-grid .input { font-family: var(--mono); letter-spacing: .08em; }
.md { display: flex; align-items: center; gap: 6px; }
.md .input { text-align: center; padding: 0 6px; }
.md em { font-style: normal; color: var(--ink-2); }
.id-act { display: flex; align-items: center; gap: 16px; margin-top: 16px; flex-wrap: wrap; }
.id-act .btn { min-width: 120px; }
.note { margin: 0; font-size: 13px; color: var(--ink-3); flex: 1; min-width: 200px; }
.id-result { margin-top: 14px; }
.id-result:empty { display: none; }
.calc { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 8px; background: var(--bg-3); font-size: 15px; color: var(--ink-2); }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--bot-red-20); border-top-color: var(--bot-red); animation: spin .7s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.match { padding: 12px 14px; border-radius: 8px; background: var(--ok-bg); }
.match .ok-line { gap: 10px; flex-wrap: wrap; }
.kv-hash { margin-top: 8px; display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; font-size: 14px; }
.kv-hash .k { margin: 0; }
.tx-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.tx-row .tx-sec { margin-bottom: 16px; }
.ok-line { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 14px; color: var(--ok); }
.err-line { margin-top: 10px; font-size: 14px; color: var(--bad); }
.err-line:empty { display: none; }
.hint-line { margin-top: 10px; font-size: 13px; color: var(--ink-3); text-align: center; }
.tx-gone { padding: 30px 10px; text-align: center; color: var(--bad); font-size: 17px; }
.success { text-align: center; padding: 6px 0 18px; }
.success .big { width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 12px; display: grid; place-items: center; background: var(--ok); color: #fff; animation: pop .35s ease; }
.success h2 { justify-content: center; margin: 0 0 4px; font-size: 24px; }
.success p { margin: 0; color: var(--ink-2); font-size: 15px; }
.sub-h { margin: 6px 0 14px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 16px; font-weight: 600; }
@keyframes pop { 0% { transform: scale(.6); } 70% { transform: scale(1.1); } 100% { transform: scale(1); } }
.chain { list-style: none; margin: 14px 0 0; padding: 0; }
.chain li { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; font-size: 14px; color: var(--ink-2); }
.chain li svg { color: var(--ok); margin-top: 2px; }
.done-act { display: flex; gap: 12px; margin-top: 20px; flex-wrap: wrap; }
.done-act .btn { flex: 1; min-width: 180px; }
.crumb a { color: var(--ink-2); text-decoration: none; }
.crumb a:hover { color: var(--bot-red); text-decoration: underline; }
.crumb b { overflow: hidden; text-overflow: ellipsis; }

/* 掃描 QR 視窗 */
.scanner { position: relative; height: 240px; border-radius: 8px; background: #eef3fb; margin-bottom: 14px; overflow: hidden; }
.scanner i { position: absolute; width: 30px; height: 30px; border: 3px solid #fff; }
.scanner i:nth-child(1) { top: 36px; left: 60px; border-right: 0; border-bottom: 0; }
.scanner i:nth-child(2) { top: 36px; right: 60px; border-left: 0; border-bottom: 0; }
.scanner i:nth-child(3) { bottom: 36px; left: 60px; border-right: 0; border-top: 0; }
.scanner i:nth-child(4) { bottom: 36px; right: 60px; border-left: 0; border-top: 0; }
.scanner .laser { position: absolute; left: 60px; right: 60px; height: 2px; background: rgba(154, 0, 54, .7); box-shadow: 0 0 8px rgba(154, 0, 54, .6); animation: laser 2s ease-in-out infinite alternate; }
@keyframes laser { from { top: 50px; } to { top: 188px; } }
.scanner .cap { position: absolute; left: 0; right: 0; bottom: 10px; text-align: center; font-size: 13px; color: #6b7a90; }

/* toast */
.t-toast { position: fixed; z-index: 90; top: calc(var(--safe-t) + 76px); right: calc(var(--safe-r) + 20px); max-width: min(380px, calc(100% - 32px)); display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--bot-red); border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .14); animation: toastIn .3s ease; font-size: 15px; }
.t-toast b { display: block; }
.t-toast small { color: var(--ink-3); }
@keyframes toastIn { from { transform: translateY(-12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- iPad 直式（側欄預設收合成圖示列） ---------- */
@media (max-width: 1279px) {
  .tbl .hide-md { display: none; }
}
@media (max-width: 1179px) {
  .tbl .hide-lg { display: none; }
  .tbl td, .tbl th { padding-left: 10px; padding-right: 10px; }
  .t-content { padding: 22px 24px calc(var(--safe-b) + 36px); }
  .stat .v { font-size: 30px; }
  .tbl .hide-md { display: none; }
}

/* ---------- iPhone（側欄改抽屜，表格改卡片） ---------- */
@media (max-width: 767px) {
  .t-layout, .t-layout.collapsed { grid-template-columns: minmax(0, 1fr); }
  .t-side { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; transform: translateX(-105%); transition: transform .25s ease; box-shadow: 10px 0 40px rgba(0, 0, 0, .15); }
  .t-layout.collapsed .t-side .side-logo .full, .t-layout.collapsed .side-item .lbl, .t-layout.collapsed .side-item em, .t-layout.collapsed .side-group span, .t-layout.collapsed .side-foot span { display: initial; }
  .t-layout.collapsed .side-logo .mark { display: none; }
  .t-layout.collapsed .side-item { justify-content: flex-start; padding: 0 12px; }
  .t-layout.drawer-open .t-side { transform: none; }
  .t-layout.drawer-open .side-mask { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 0, .3); }
  .side-foot .icon-btn { display: none; }
  .menu-btn { display: grid; margin-left: -8px; }
  .t-top { padding: calc(var(--safe-t) + 6px) 12px 6px; gap: 6px; min-height: 58px; }
  .crumb { font-size: 14px; }
  .crumb .lv1, .crumb .lv2, .crumb .chev { display: none; }
  .crumb { overflow: hidden; flex: 1; }
  .crumb .sn { display: none; }
  .nametag { padding: 4px; border: 0; min-height: 44px; }
  .nametag .nt { display: none; }
  .conn-pill { padding: 0 10px; }
  .conn-pill span { display: none; }
  .t-content { padding: 18px 16px calc(var(--safe-b) + 32px); }
  .t-content h1 { font-size: 24px; }
  .tabs button { font-size: 16px; padding: 0 10px; }
  .stats { gap: 8px; margin-bottom: 18px; }
  .stat { padding: 12px; }
  .stat .k { font-size: 13px; }
  .stat .k svg { display: none; }
  .stat .v { font-size: 24px; }
  .stat .v small { font-size: 13px; margin-left: 2px; }
  .stat .s { font-size: 11px; }
  .card-h { padding: 14px 14px 8px; flex-wrap: wrap; }
  .card-h h2 { font-size: 17px; }
  /* 表格改卡片 */
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl tr { position: relative; margin: 0 12px 10px; width: auto; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
  .tbl td { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border: 0; font-size: 15px; text-align: right; white-space: normal; background: transparent !important; animation: none !important; }
  .tbl tr.is-new { background: #fffbea; border-color: #f0dca0; animation: newFlash 1.2s ease 3; }
  .tbl td::before { content: attr(data-label); color: var(--ink-3); text-align: left; flex: none; font-size: 14px; }
  .tbl td.newcell { position: absolute; top: 10px; right: 12px; width: auto; padding: 0; }
  .tbl td.newcell::before, .tbl td.act::before, .tbl td.lead::before { display: none; }
  .tbl td.lead { justify-content: flex-start; padding-right: 50px; text-align: left; }
  .tbl td.act { justify-content: stretch; padding-top: 8px; }
  .tbl td.act .btn { width: 100%; }
  .tbl .hide-md, .tbl .hide-lg { display: flex; }
  .tbl .hide-sm { display: none; }
  .tx-head { gap: 8px; }
  .tx-title h1 { font-size: 21px !important; }
  .tx-title .serial { font-size: 18px; }
  .stepper { gap: 4px; }
  .stepper span { flex-direction: column; align-items: flex-start; gap: 4px; font-size: 12px; white-space: normal; }
  .tx-sec { padding: 14px 14px 16px; }
  .kv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .id-grid, .tx-row { grid-template-columns: 1fr; }
  .id-act .btn { width: 100%; }
  .done-act .btn { min-width: 100%; }
  .t-toast { top: auto; bottom: calc(var(--safe-b) + 16px); right: 16px; left: 16px; max-width: none; }
}

/* ---------- 多家銷售機構 ---------- */
.bank-chip { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-weight: 500; }
.bank-chip img { width: 22px; height: 22px; object-fit: contain; flex: none; }
.bank-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: -8px 0 22px; }
.bs { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; padding: 12px 14px; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: 10px; }
.bs img { grid-row: 1 / 3; width: 34px; height: 34px; object-fit: contain; }
.bs .nm { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bs .ct { font-size: 13px; color: var(--ink-3); white-space: nowrap; }
.bs .ct b { color: var(--ink); font-size: 15px; }
.bs.has { background: #fffbea; }
.t-toast .tl { width: 34px; height: 34px; object-fit: contain; flex: none; }
@media (max-width: 1179px) {
  .bank-stats { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 767px) {
  .bank-stats { grid-template-columns: 1fr 1fr; gap: 8px; margin: -8px 0 16px; }
  .bs { padding: 10px; }
  .bs img { width: 28px; height: 28px; }
  .bs .nm { font-size: 14px; }
}
