/* 淺色側邊欄＋淡色內容,無框架;v3 主題:霧感深海藍×香檳金×淺冷灰
   (僅 CSS,不動模板;語意色與 @media print 原樣保留) */
* { box-sizing: border-box; }
:root {
  --side-bg: #FBFCFD;        /* 側欄轉淺:近白面 */
  --side-bg2: #F5F7FA;
  --side-line: #E2E7EE;
  --side-text: #3D4C63;
  --side-muted: #6E6E6E;     /* 規範 #777777 對 #F5F7FA 實算 4.17:1,依驗收調深 */
  --accent: #244370;         /* 霧感深海藍 */
  --accent-soft: rgba(36, 67, 112, 0.08);
  --gold: #C8B48C;           /* 香檳金:僅細節點綴 */
  --gold-soft: rgba(200, 180, 140, 0.18);
  --page-bg: #F5F7FA;
  --ink: #2A2A2A;
  --muted: #6E6E6E;          /* 同上,由 #777777 調深保 4.5:1 */
  --line: #E2E7EE;
  --card-bg: #fff;
  --card-shadow: 0 1px 3px rgba(36, 67, 112, 0.07);
  --btn: #244370;
  --btn-hover: #1B3459;
  --danger: #dc2626;
  --focus-ring: 0 0 0 3px rgba(36, 67, 112, 0.22);
}
body {
  margin: 0;
  font-family: "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--page-bg);
}
h1 { font-size: 1.35rem; font-weight: 700; margin: 0.2rem 0 1rem;
  letter-spacing: 0.01em; }
h2 { font-size: 1.05rem; font-weight: 700; margin: 1.4rem 0 0.6rem; }
/* 香檳金點綴之二:h1 下方短金線(僅螢幕;列印版面不加飾線) */
@media screen {
  h1::after {
    content: "";
    display: block;
    width: 36px;
    height: 2px;
    margin-top: 0.3rem;
    border-radius: 1px;
    background: var(--gold);
  }
}
a { color: var(--accent); }

/* ===== 版面:固定左側欄 + 內容區 ===== */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 220px;
  background: var(--side-bg);
  border-right: 1px solid var(--side-line);
  color: var(--side-text);
  display: flex;
  flex-direction: column;
  z-index: 40;
}
.side-brand {
  padding: 1.15rem 1rem 0.95rem;
  border-bottom: 1px solid var(--side-line);
}
.side-brand-name {
  display: block;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
}
.side-brand-sub {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.75rem;
  letter-spacing: 0.35em;
  color: var(--side-muted);
}
.side-nav { flex: 1; overflow-y: auto; padding: 0.7rem 0.5rem 0.5rem; }
.side-group { margin-bottom: 0.9rem; }
.side-group-label {
  padding: 0.25rem 0.6rem;
  font-size: 0.7rem;
  letter-spacing: 0.25em;
  color: var(--side-muted);
}
.side-link {
  display: block;
  margin: 1px 0;
  padding: 0.42rem 0.6rem;
  border-radius: 8px;
  border-left: 3px solid transparent;
  color: var(--side-text);
  text-decoration: none;
  font-size: 0.95rem;
  transition: background 0.12s, color 0.12s;
}
.side-link:hover { background: var(--accent-soft); color: var(--accent); }
.side-link.active {
  background: var(--accent-soft);
  border-left-color: var(--gold);  /* 金色點綴主舞台 */
  color: var(--accent);
  font-weight: 600;
}
.side-user {
  padding: 0.8rem 1rem;
  border-top: 1px solid var(--side-line);
  font-size: 0.85rem;
  background: #EFF2F6;
}
.side-user-name {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  color: var(--side-text);
  margin-bottom: 0.45rem;
}
.role-badge {
  font-size: 0.7rem;
  padding: 0.08rem 0.5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);  /* 對照表 #7B93B6 在淺底僅約 2.7:1,小字改主色保可讀 */
}
.side-user-actions { display: flex; align-items: center; gap: 0.9rem; }
.side-user-actions a {
  color: var(--side-muted);
  text-decoration: none;
}
.side-user-actions a:hover { color: var(--accent); text-decoration: underline; }
.logout-form { display: inline; }
.inline-form { display: inline; }
button.linklike {
  border: 0;
  padding: 0;
  background: none;
  color: var(--side-muted);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
button.linklike:hover { color: var(--accent); text-decoration: underline; }

.content { min-height: 100vh; }
body.has-nav .content { margin-left: 220px; }
/* 內容區全寬:列表吃滿版面;表單卡各有自身 max-width 不受影響 */
main { margin: 0 auto; padding: 24px 28px; }

/* 行動版頂列與遮罩(桌機隱藏)
   checkbox 用 clip 隱藏而非 display:none:保留鍵盤 tab 與輔助科技可及性 */
.nav-toggle {
  position: absolute;
  width: 1px; height: 1px;
  clip: rect(0 0 0 0); clip-path: inset(50%);
  overflow: hidden; white-space: nowrap;
}
.nav-toggle:focus-visible ~ .topbar .nav-burger { box-shadow: var(--focus-ring); }
.topbar { display: none; }
.nav-backdrop { display: none; }

/* ===== 表格:白卡、圓角、表頭吸頂、列 hover ===== */
table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--card-shadow);
}
th, td { border: 0; border-bottom: 1px solid var(--line); padding: 0.48rem 0.7rem; text-align: left; }
th {
  background: #F5F7FA;
  font-size: 0.78rem;
  font-weight: 600;
  color: #556070;
  letter-spacing: 0.04em;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
thead th:first-child { border-top-left-radius: 10px; }
thead th:last-child { border-top-right-radius: 10px; }
tr:last-child > td { border-bottom: 0; }
tr:last-child > td:first-child { border-bottom-left-radius: 10px; }
tr:last-child > td:last-child { border-bottom-right-radius: 10px; }
tbody tr:hover > td { background: #F2F5F9; }
td { font-variant-numeric: tabular-nums; }

/* 併儲存格(未交貨清單):合併欄靠上對齊;末組合併欄延伸到表底,
   不歸 tr:last-child 管,補去底線 */
td[rowspan] { vertical-align: top; }
tr.grp-end > td[rowspan] { border-bottom: 0; }

/* 維護頁通用 */
td.num, th.num { text-align: right; }
tr.inactive td { color: #999; background: #fafafa; }
tr.neg td { color: #b00020; font-weight: bold; }  /* 負庫存紅字 */
tr.low td { background: #fff8e1; }  /* 低於安全存量亮黃 */
tr.lot-expired td, td.lot-expired { color: #b00020; background: #fde8e8;
  font-weight: bold; }  /* 批號已過期紅 */
tr.lot-near td, td.lot-near { background: #fff8e1; }  /* 效期將至亮黃 */
.lot-picks { display: flex; flex-direction: column; gap: 0.3rem;
  margin-bottom: 0.4rem; }  /* 確認出貨手動指定批 */
.low-tag { color: #b45309; font-size: 0.75rem; font-weight: bold; }
td.age.overdue { color: #b00020; font-weight: bold; }  /* 帳齡超期紅字 */
.hint { color: var(--muted); font-size: 0.85rem; }

/* ===== 訊息橫幅 ===== */
.error {
  background: #fef2f2;
  border-left: 4px solid var(--danger);
  border-radius: 0 8px 8px 0;
  color: #b91c1c;
  padding: 0.55rem 0.85rem;
  box-shadow: var(--card-shadow);
}
.error:empty { display: none; }
.warn {  /* 黃色警示(不擋流程):如出貨配到已過期批號 */
  background: #fffbeb;
  border-left: 4px solid #d97706;
  border-radius: 0 8px 8px 0;
  color: #92400e;
  padding: 0.55rem 0.85rem;
  box-shadow: var(--card-shadow);
}
.ok-msg {
  background: #f0fdf4;
  border-left: 4px solid #16a34a;
  border-radius: 0 8px 8px 0;
  color: #15803d;
  font-weight: 600;
  padding: 0.55rem 0.85rem;
  box-shadow: var(--card-shadow);
}

/* ===== 按鈕:主要(藍)/次要(白框)/危險(紅) ===== */
button { font: inherit; }
button:not(.linklike):not(.pick-btn) {
  background: var(--btn);
  color: #fff;
  border: 0;
  border-radius: 7px;
  padding: 0.45rem 1.1rem;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(36, 67, 112, 0.25);
  transition: background 0.12s, transform 0.05s;
}
button:not(.linklike):not(.pick-btn):hover { background: var(--btn-hover); }
button:not(.linklike):not(.pick-btn):active { transform: translateY(1px); }
a.btn {
  display: inline-block;
  padding: 0.4rem 1rem;
  background: #fff;
  color: var(--ink);
  border: 1px solid #d1d5db;
  border-radius: 7px;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s;
}
a.btn:hover { background: #f3f4f6; border-color: #9ca3af; }
button.danger, a.btn.danger {
  background: var(--danger);
  border: 0;
  color: #fff;
  box-shadow: 0 1px 2px rgba(220, 38, 38, 0.25);
}
button.danger:hover, a.btn.danger:hover { background: #b91c1c; }

/* ===== 表單控制項:一致高度、邊框與 focus 圈 ===== */
input[type="text"], input[type="password"], input[type="number"],
input[type="date"], input[type="month"], input[type="search"],
input[type="tel"], input[type="email"], input[type="file"],
select, textarea {
  font: inherit;
  color: inherit;
  background: #fff;
  padding: 0.4rem 0.55rem;
  border: 1px solid #D5DBE3;
  border-radius: 7px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

/* ===== 登入卡 ===== */
body:has(.login-box) {
  background:
    radial-gradient(60rem 30rem at 85% -10%, rgba(36, 67, 112, 0.14), transparent),
    radial-gradient(50rem 26rem at -10% 110%, rgba(27, 52, 89, 0.10), transparent),
    var(--page-bg);
}
.login-box {
  max-width: 21rem;
  margin: 4.5rem auto;
  padding: 1.8rem 1.6rem 1.6rem;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 10px 32px rgba(36, 67, 112, 0.12);
}
.login-box label { display: block; margin-bottom: 0.85rem; }
.login-box input {
  display: block;
  width: 100%;
  margin-top: 0.28rem;
  font-size: 1rem;
}
.login-box button { width: 100%; padding: 0.58rem; font-size: 1rem; }

/* ===== 搜尋列與編輯表單 ===== */
.search-form { margin: 0.8rem 0; display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.search-form a.current { font-weight: bold; }
.edit-form {
  max-width: 26rem;
  padding: 1.2rem;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
}
.edit-form label { display: block; margin-bottom: 0.8rem; }
.edit-form label.checkbox { display: flex; gap: 0.4rem; align-items: center; }
.edit-form input[type="text"], .edit-form select { display: block; width: 100%; margin-top: 0.25rem; }

/* ===== 打單頁/庫存單據 ===== */
.order-form {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  padding: 1.2rem;
  max-width: 72rem;  /* 表單不隨全寬版面無限伸展 */
}
.order-head { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.8rem; }
.order-head label, .cust-box label { display: block; }
.cust-box { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 0.8rem;
  padding: 0.6rem 0.8rem; display: flex; gap: 1rem; flex-wrap: wrap; background: #F5F7FA; }
/* 地址常見 20~40 字:給滿版寬(flex 換行至獨立列),小螢幕自動縮 */
.cust-box label:has(#cust-address) { flex: 1 1 100%; }
#cust-address { width: 100%; max-width: 34rem; display: block;
  margin-top: 0.25rem; }
.prod-cell { position: relative; min-width: 16rem; }
.suggest { position: absolute; z-index: 10; background: #fff;
  border: 0 solid #bbb; border-radius: 8px; max-width: 24rem; overflow: hidden; }
.suggest:not(:empty) { border-width: 1px; box-shadow: 0 8px 22px rgba(36, 67, 112, 0.16); }
label { position: relative; }
.suggest-item { padding: 0.32rem 0.6rem; cursor: pointer; white-space: nowrap; }
.suggest-item.first, .suggest-item:hover { background: #E8EDF4; }
/* 明細表自適應:輸入填滿儲存格,數字/批號/日期欄給固定欄寬 */
.lines-table input, .lines-table select { width: 100%; }
.lines-table td:has(.qty) { width: 6rem; }
.lines-table td:has(.price), .lines-table td:has(.unit-cost) {
  width: 9.5rem; }
.lines-table td:has(.lot-no), .lines-table td:has(.lot-expiry),
.lines-table td:has(.lot-pick) { width: 11rem; }
.lines-table td:has(.del-row) { width: 3.6rem; }
.lines-table .del-row { width: auto; }
.totals { font-size: 1.1rem; }
.totals span, .totals strong { margin-right: 1.2rem; }
.actions button { padding: 0.5rem 1.4rem; font-size: 1rem; }
.shortage-box { background: #fff2f2; border: 1px solid #e0b4b4;
  border-radius: 10px; padding: 0.6rem 1rem; }

/* ===== 主持人手機開單:大按鈕 ===== */
.host-form {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  padding: 1rem;
  max-width: 28rem;
}
.host-form label { display: block; margin-bottom: 0.8rem; }
.host-form input, .host-form select {
  display: block; width: 100%; margin-top: 0.25rem;
  padding: 0.6rem;
  font-size: 1.05rem;
}
.prod-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem;
  margin-bottom: 0.8rem; }
.pick-btn {
  padding: 0.7rem 1rem; border: 1px solid #A6ADB6; border-radius: 10px;
  background: #fff; color: var(--ink); font-size: 1.05rem; cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.pick-btn:hover { background: #E8EDF4; border-color: var(--accent); }
.big-btn {
  width: 100%; padding: 0.9rem; border-radius: 10px; font-size: 1.15rem;
}
#cust-suggest { position: static; display: flex; flex-direction: column;
  gap: 0.4rem; margin-top: 0.4rem; box-shadow: none; }

/* ===== 待核可清單 ===== */
.pending-card {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  padding: 0.8rem 1rem;
  margin-bottom: 1rem;
}
.pending-card h2 { font-size: 1.05rem; margin: 0.2rem 0 0.5rem; }
.pending-actions { display: flex; gap: 1rem; align-items: flex-start;
  margin-top: 0.6rem; flex-wrap: wrap; }
.pending-actions form { display: flex; gap: 0.5rem; }
.pending-actions textarea { width: 16rem; }

/* ===== 出貨單明細/列印 ===== */
.actions-box { display: flex; gap: 1rem; align-items: flex-start;
  margin: 1rem 0; flex-wrap: wrap; }
.actions-box form { display: flex; gap: 0.5rem; }
.actions-box textarea { width: 16rem; }
.print-area {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  padding: 1rem 1.2rem;
}
.detail-lines { width: 100%; }
.pager a, .pager strong { margin-right: 0.5rem; }
.row-actions { display: flex; gap: 0.6rem; align-items: center; }

/* ===== 包裝驗貨:已核銷列 ===== */
.row-done td { color: #1f7a33; }

/* ===== 出貨看板:六狀態欄與滯留亮黃 ===== */
.board { display: grid; gap: 0.8rem;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); }
.board-col {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-top: 3px solid #D5DBE3;
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  padding: 0.6rem 0.8rem;
}
.board-col h2 { font-size: 0.95rem; margin: 0 0 0.4rem; }
.board-col ul { list-style: none; margin: 0; padding: 0; }
.board-col li { padding: 0.25rem 0.3rem; border-radius: 6px; }
.board-col li.stale { background: #fff3cd; }
.stale-mark { color: #92400e; font-size: 0.75rem; font-weight: bold; }

/* ===== 儀表板:KPI 卡與月銷長條 ===== */
.cards { display: flex; gap: 0.8rem; flex-wrap: wrap; margin: 1rem 0; }
.card {
  flex: 1 1 10rem;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-top: 1px solid var(--gold);  /* 金色點綴之三:KPI 卡頂線 */
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  padding: 0.85rem 1rem;
  transition: box-shadow 0.15s, transform 0.15s;
}
.card:hover { box-shadow: 0 6px 18px rgba(36, 67, 112, 0.10);
  transform: translateY(-1px); }
.card .l { font-size: 0.78rem; color: var(--muted); letter-spacing: 0.04em; }
.card .v { font-size: 1.45rem; font-weight: 700; margin-top: 0.2rem;
  font-variant-numeric: tabular-nums; }
.warn-title { color: #b00020; }
.chart-box {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  padding: 0.8rem 1rem;
}
.chart-row { display: flex; align-items: center; gap: 0.5rem;
  margin: 0.28rem 0; font-size: 0.85rem; }
.chart-row .mlabel { width: 3rem; color: var(--muted); }
.chart-row .clabel { width: 3.5rem; color: var(--muted); }
.chart-row .bar { height: 0.85rem; border-radius: 999px;
  background: linear-gradient(90deg, #7B93B6, var(--accent));
  max-width: 60%; }

/* ===== 健檢頁:分級卡片 ===== */
.finding {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--card-shadow);
  padding: 0.6rem 0.9rem;
  margin: 0.5rem 0;
}
.finding-msg { white-space: pre-line; margin-top: 0.3rem;
  font-size: 0.9rem; }
.f-高 { border-left: 4px solid #b00020; }
.f-中 { border-left: 4px solid #d97706; }
.f-低 { border-left: 4px solid var(--accent); }
.badge { font-size: 0.75rem; padding: 0.1rem 0.5rem; border-radius: 999px;
  color: #fff; margin-right: 0.5rem; }
.b-高 { background: #b00020; }
.b-中 { background: #d97706; }
.b-低 { background: var(--accent); }

/* ===== 行動版(≤768px):側欄改抽屜、頂列漢堡 ===== */
@media (max-width: 768px) {
  body.has-nav .content { margin-left: 0; }
  main { padding: 16px 12px; }
  .topbar {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--side-bg);
    color: var(--side-text);
    border-bottom: 1px solid var(--side-line);
    padding: 0.55rem 0.9rem;
  }
  .nav-burger { font-size: 1.3rem; line-height: 1; cursor: pointer; }
  .topbar-brand { font-weight: 700; color: var(--accent); }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    width: 240px;
  }
  .nav-toggle:checked ~ .sidebar {
    transform: none;
    box-shadow: 0 0 24px rgba(0, 0, 0, 0.45);
  }
  .nav-toggle:checked ~ .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(0, 0, 0, 0.45);
  }
  body:has(.nav-toggle:checked) { overflow: hidden; }  /* 抽屜開啟時鎖捲動 */
  /* 寬表格改為橫向捲動,避免撐破頁面 */
  table { display: block; overflow-x: auto; max-width: 100%; }
  th { position: static; }
  /* iOS 聚焦輸入框不放大 */
  input, select, textarea { font-size: 16px; }
}

/* ===== 列印:A5 出貨單版面,隱藏側欄/頂列與操作 ===== */
@media print {
  @page { size: A5; margin: 8mm; }
  .sidebar, .topbar, .nav-backdrop, .nav-toggle, .no-print { display: none !important; }
  body { background: #fff; }
  body.has-nav .content { margin-left: 0; }
  main { max-width: none; margin: 0; padding: 0; }
  .print-area { border: 0; border-radius: 0; padding: 0; box-shadow: none; }
  .print-area h1 { font-size: 1.2rem; margin: 0 0 0.4rem; }
  table { border: 0; border-radius: 0; box-shadow: none; }
  th { position: static; }
  .detail-lines { border-collapse: collapse; }
  .detail-lines th { background: #fff; }
  .detail-lines th, .detail-lines td { border: 1px solid #ddd; }
}

/* 條碼標籤(P2-8):多枚網格,列印每枚不拆頁 */
.label-sheet { display: flex; flex-wrap: wrap; gap: 4mm; }
.label-cell { width: 60mm; padding: 2mm; border: 1px dashed #bbb;
              text-align: center; break-inside: avoid; }
.label-cell svg { max-width: 100%; height: auto; }
.label-name { font-size: 12px; }
.label-code { font-size: 11px; color: #444; }
@media print { .label-cell { border: none; } }
.scan-flash td { background: #dff5df; }

/* ===== 頁碼列(全站列表 50 筆/頁) ===== */
.pager { display: flex; gap: 0.35rem; align-items: center;
  flex-wrap: wrap; margin: 0.9rem 0; }
.pager a, .pager strong {
  min-width: 2rem; text-align: center; padding: 0.25rem 0.55rem;
  border: 1px solid var(--line); border-radius: 7px;
  background: var(--card-bg); text-decoration: none;
  font-variant-numeric: tabular-nums;
}
.pager strong { background: var(--btn); border-color: var(--btn);
  color: #fff; }
.pager a:hover { border-color: var(--accent); }
.pager .ellip { color: var(--muted); padding: 0 0.15rem; }
.pager-info { color: var(--muted); margin-right: 0.4rem; }

/* ===== 發票狀態章(發票域併入) ===== */
.chip {
  display: inline-block;
  padding: 0.12rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}
.c-bundle {  /* 促銷組合標籤:橘系促銷感,與狀態色區隔 */
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #fed7aa;
}
.s-pending  { background: #fef3c7; color: #92400e; }
.s-sent     { background: #E8EDF4; color: #1B3459; }
.s-uploaded { background: #E8EDF4; color: #1B3459; }
.s-accepted, .s-done { background: #d1fae5; color: #065f46; }
.s-failed   { background: #fee2e2; color: #991b1b; }
.s-void     { background: #e5e7eb; color: #4b5563; }
.s-obsolete { background: #ede9fe; color: #5b21b6; }

/* 組合收合列(打單/購物車):一列一套,點按展開明細 */
.bundle-head td {
  background: #E8EDF4;
  font-weight: 600;
  cursor: pointer;
}
.bundle-head .del-row { cursor: pointer; }
/* 明細頁組合卡頭:靜態展示非點按收合,不給手型 */
.detail-lines .bundle-head td { cursor: default; }

/* 業務員開單:已選客戶卡片(仿結帳收件人:地址上、姓名電話下、
   右側 ✎ 重選) */
.cust-card {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  padding: .7rem .9rem;
  margin: .5rem 0;
  background: #F5F7FA;
  border: 1px solid var(--line);
  border-radius: .6rem;
}
.cust-card .cc-pin { line-height: 1.4; }
.cust-card .cc-info { flex: 1; min-width: 0; }
.cust-card .cc-addr {
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.4;
  word-break: break-all;
}
.cust-card .cc-sub {
  color: var(--muted);
  margin-top: .15rem;
}
.cust-card .cc-sub span + span { margin-left: .6rem; }
.cust-card { cursor: pointer; }
.cust-card .cc-chevron {
  color: #A6ADB6;
  font-size: 1.4rem;
  line-height: 1.2;
  flex-shrink: 0;
}
.addr-panel .addr-opt.addr-current {
  border-color: var(--btn);
  font-weight: 700;
}
.addr-panel .addr-actions {
  display: flex;
  justify-content: space-between;
  margin-top: .5rem;
  padding-top: .4rem;
  border-top: 1px solid #F5F7FA;
}

/* 業務員開單:結帳版型(卡片段落+數量加減+底部固定送出列) */
.checkout { max-width: 34rem; }
.checkout-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: .6rem;
  padding: .8rem .9rem;
  margin-bottom: .7rem;
}
.ck-title { font-weight: 700; margin-bottom: .5rem; }
.checkout-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  padding: .45rem 0;
}
.checkout-row + .checkout-row { border-top: 1px solid #F5F7FA; }
.checkout-row .ck-label { color: #556070; white-space: nowrap; }
.checkout-row select, .checkout-row input[type="text"] {
  flex: 1;
  margin: 0;
}
.checkout-row.ck-strong { font-weight: 700; font-size: 1.05rem; }
.citem { padding: .55rem 0; border-top: 1px solid #F5F7FA; }
.citem:first-child { border-top: 0; }
.ci-main {
  display: flex;
  justify-content: space-between;
  gap: .8rem;
}
.ci-name { font-weight: 600; }
.ci-price { color: #dc2626; font-weight: 700; white-space: nowrap; }
.ci-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: .35rem;
}
.stepper { display: inline-flex; align-items: center; gap: .2rem; }
.stepper .qty {
  width: 3.2rem;
  text-align: center;
  margin: 0;
}
.stepper .stp {
  width: 2rem;
  height: 2rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #D5DBE3;
  background: #F5F7FA;
  color: #3D4C63;
  border-radius: .35rem;
  font-size: 1.1rem;
  line-height: 1;
}
.stepper .stp:disabled { opacity: .35; }
/* 組合摘要卡:與商品卡同構同對齊,不另包色塊 */
.bundle-head-card { padding: .55rem 0; border-top: 1px solid #F5F7FA; }
.bundle-head-card .ci-main { cursor: pointer; }
.bundle-head-card .bh-name { font-weight: 600; }
.bundle-head-card .bh-sets { width: 3.2rem; text-align: center;
  margin: 0; background: #F5F7FA; }
.checkout-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: #fff;
  border-top: 2px solid var(--line);
  padding: .6rem .2rem;
  margin-top: .4rem;
}
.ck-bar-total strong { color: #dc2626; font-size: 1.25rem; }
.checkout-bar .big-btn { margin: 0; min-width: 55%; }


/* 業務員開單:地址選擇面板 */
.addr-panel {
  margin-top: .5rem;
  padding: .6rem .7rem;
  background: #fff;
  border: 1px dashed #A6ADB6;
  border-radius: .5rem;
}
.addr-panel .addr-opt {
  display: block;
  width: 100%;
  text-align: left;
  margin-bottom: .35rem;
}
.addr-panel .addr-new {
  display: flex;
  gap: .5rem;
  margin-top: .3rem;
}
.addr-panel .addr-new input { flex: 1; margin: 0; }
.cust-card .cc-addr { cursor: pointer; }

/* 業務員手機清單卡片(未收清單等) */
.olist { max-width: 34rem; }
.ocard {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: .6rem;
  padding: .7rem .9rem;
  margin-bottom: .6rem;
}
.ocard .oc-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .8rem;
}
.ocard .oc-no { font-weight: 700; text-decoration: none; }
.ocard .oc-amt { color: #dc2626; font-weight: 700; }
.ocard .oc-sub {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem .8rem;
  color: var(--muted);
  margin-top: .25rem;
  align-items: center;
}
.ocard .oc-actions { margin-top: .5rem; text-align: right; }

/* 業務員庫存/預訂卡片:自由可訂為決策主數字 */
.stock-card .sk-name { font-weight: 700; }
.stock-card .sk-nums {
  display: flex;
  gap: 1.2rem;
  align-items: center;
  margin-top: .2rem;
}
/* 預訂鈕固定卡片右下角(兩種卡同位);卡片預留底部空間避免壓字 */
.stock-card { position: relative; }
.stock-card:has(.reserve-btn) { padding-bottom: 2.9rem; }
.stock-card .reserve-btn {
  position: absolute;
  right: .9rem;
  bottom: .6rem;
}
.stock-card .sk-free { color: #16a34a; font-weight: 600; }
.stock-card .sk-free strong { font-size: 1.25rem; }
.stock-card .reserve-btn {
  border: 1px solid var(--btn);
  color: var(--btn);
  background: #fff;
  border-radius: .4rem;
  padding: .3rem .9rem;
}
.stock-card .reserve-row { margin-top: .5rem; }
/* 展開表單:欄位一排、「確定預訂」獨立一行在下(兩種卡同款) */
.reserve-row .inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem .9rem;
  align-items: flex-end;
}
.reserve-row .inline-form .rv-actions {
  flex-basis: 100%;
  display: flex;
  gap: .6rem;
  margin-top: .2rem;
}
.reserve-row .inline-form button[type="submit"] {
  flex: 1;
  padding: .55rem;
}
.reserve-row .inline-form .rv-cancel {
  padding: .55rem .9rem;
  background: #F5F7FA;
  color: #3D4C63;  /* 全站按鈕白字,淺底需覆寫 */
  border: 1px solid #D5DBE3;
  border-radius: .35rem;
}
/* 加減鈕中的數字置中;整組靠列右側(標籤左、控制右) */
.reserve-row .stepper input {
  width: 3.4rem;
  text-align: center;
  margin: 0;
}
.reserve-row .rv-line .stepper { margin-left: auto; }
.reserve-row .rv-line input[type="date"] {
  flex: 0 0 auto;
  margin-left: auto;
  width: 11rem;
}
.reserve-row .inline-form .hint { flex-basis: 100%; }
.reserve-row .inline-form .rv-line {
  flex-basis: 100%;
  display: flex;
  align-items: center;
  gap: .6rem;
  margin: 0;
}
.reserve-row .inline-form .rv-line input[type="date"] { flex: 1; }

/* 我的預訂列:左=名稱+灰字、右=剩餘+釋放(固定不換行對齊) */
.myrv {
  display: flex;
  align-items: flex-start;
  gap: .8rem;
  padding: .45rem 0;
}
.myrv + .myrv { border-top: 1px solid #F5F7FA; }
.myrv .mr-main { flex: 1; min-width: 0; }
.myrv .mr-side {
  display: flex;
  align-items: center;
  gap: .5rem;
  white-space: nowrap;
  margin-left: auto;
}
.myrv .mr-side form { display: inline; margin: 0; }
.myrv .mr-remain { color: #16a34a; font-weight: 600; }
.myrv .mr-until { display: block; margin-top: .1rem; }

/* 我的預訂收合摘要列 */
.myrv-toggle {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.myrv-toggle .mr-caret { color: #A6ADB6; }
#myrv-list { margin-top: .3rem; }

.warn-text { color: #b45309; }

/* 電子發票證明聯(57mm 熱感版式) */
.einv-stub { width: 57mm; margin: 0 auto; }
.einv-stub p { margin: .12rem 0; }
.es-co, .es-meta { font-size: .78rem; text-align: center; }
.es-title {
  font-size: 1.15rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: .3em;
}
.es-big { font-size: 1.3rem; font-weight: 700; text-align: center; }
.es-bar svg { width: 100%; height: 10mm; }
.es-qrs { display: flex; justify-content: space-between; gap: 2mm; }
.es-qr svg { width: 20mm; height: 20mm; }
.einv-detail { margin-top: 1rem; border-top: 1px dashed #D5DBE3;
  padding-top: .6rem; }  /* 螢幕上與證明聯分段;列印換頁裁切 */
.ed-title { text-align: center; font-weight: 700; }
.ed-head { color: #3D4C63; }
.ed-desc { font-size: .85rem; margin-bottom: 0; }
.ed-nums { font-size: .85rem; text-align: right;
  font-variant-numeric: tabular-nums; }
.ed-total { font-weight: 700; text-align: right;
  border-top: 1px solid #A6ADB6; padding-top: .2rem; }


/* 客戶編輯:左表單右地址簿(窄螢幕自動疊回直式) */
.cust-grid {
  display: flex;
  gap: 1.2rem;
  align-items: flex-start;
  flex-wrap: wrap;
}
.cust-grid .edit-form { flex: 1 1 320px; }
.cust-aside { flex: 1 1 300px; min-width: 280px; }
.cust-aside h2 { margin-top: 0.2rem; }
.cust-aside .ca-add { display: flex; gap: 0.5rem;
  margin-bottom: 0.6rem; }
.cust-aside .ca-add input { flex: 1; min-width: 0; }


/* 可搜尋下拉容器(suggest 絕對定位掛點) */
.combo { position: relative; display: block; }


/* 使用者表單:區塊勾選 */
.area-grants { border: 1px solid var(--line); border-radius: 8px;
  padding: 0.6rem 0.8rem; margin: 0.6rem 0; }
.area-grants legend { font-size: 0.85rem; color: #556070;
  padding: 0 0.3rem; }
.area-grants .area-item { display: inline-flex; align-items: center;
  gap: 0.3rem; margin: 0.15rem 0.9rem 0.15rem 0; font-size: 0.92rem; }
