/* =============================================================
   手機（<768）新樣子：照 PR #108 PJ 的手機版設計稿（docs/design/mobile-prototype 在那個 PR 的分支上，沒 merge，只當參考）。
   index.html 用 media="(max-width: 767px)" 載入，所以這裡的規則只在手機生效；電腦、iPad 照舊（Dennis 2026-11-12：只換手機）。
   第 1 步：顏色、字型、☰ 選單。進貨入庫的卡片版面是下一步。
   營業收入單獨頁（/revenue/）沒有載入這份。
   ============================================================= */

/* ---- 字型：英文數字用 Roboto（每個 11KB，只含英數）；中文用手機自己的字（iPhone 蘋方、Android 思源）。
   設計稿的 Noto Sans TC 一個字重就 1MB，手機用行動網路會載很久，所以不帶 ---- */
@font-face {
  font-family: "Roboto";
  font-display: swap;
  font-weight: 400;
  src: url("../fonts/roboto-regular-400.woff2") format("woff2");
  unicode-range: U+0020, U+0024, U+002A, U+0030-0039, U+0041-005A, U+0061-007A;
}
@font-face {
  font-family: "Roboto";
  font-display: swap;
  font-weight: 500;
  src: url("../fonts/roboto-regular-500.woff2") format("woff2");
  unicode-range: U+0020, U+0024, U+002A, U+0030-0039, U+0041-005A, U+0061-007A;
}
@font-face {
  font-family: "Roboto";
  font-display: swap;
  font-weight: 700;
  src: url("../fonts/roboto-regular-700.woff2") format("woff2");
  unicode-range: U+0020, U+0024, U+002A, U+0030-0039, U+0041-005A, U+0061-007A;
}

/* ---- 設計 token（照設計稿 css/tokens.css：央廚綠 11 階＋中性色＋狀態色） ---- */
:root {
  --brand-50: #f1f6f2;
  --brand-100: #e5ebe3;
  --brand-200: #cddcd1;
  --brand-300: #8eab99;
  --brand-350: #4f7a62;
  --brand-400: #2c5440;
  --brand-450: #1f3d2c;
  --brand-500: #1b3625;
  --brand-600: #18301f;
  --brand-700: #122417;
  --brand-800: #0c180f;

  --neutral-0: #ffffff;
  --neutral-100: #f6f7f7;
  --neutral-200: #eef0f0;
  --neutral-300: #d9dbdc;
  --neutral-400: #b1b2b2;
  --neutral-500: #757680;
  --neutral-600: #5e5f6b;
  --neutral-700: #494a57;
  --neutral-800: #0c0e1f;

  --warning-bg: #fcf1ed;
  --warning-text: #994000;
  --warning-icon: #f06f13;
  --error-bg: #faedee;
  --error-text: #b22b34;
  --error-border: #d7333d;
  --success-bg: #ebf8f7;
  --success-text: #005249;

  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --header-height: 56px;

  /* 舊的顏色名字（app.css 全部用這些）換成設計稿的顏色：米色底 → 白底、赤陶色主要按鈕 → 央廚綠 */
  --green: var(--brand-450);
  --green-2: var(--brand-400);
  --green-soft: var(--brand-100);
  --cream: var(--neutral-0);
  --card: var(--neutral-0);
  --line: var(--neutral-300);
  --text: var(--neutral-800);
  --muted: var(--neutral-600);
  --terracotta: var(--brand-450);
  --terracotta-dark: var(--brand-500);
  --alert: var(--error-border);
  --danger: var(--error-text);
  --warn-bg: var(--warning-bg);
  --radius: var(--radius-md);

  font-family: "Roboto", -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

html,
body {
  overflow-x: clip;
}

/* 選單打開時後面的頁面不要跟著捲 */
html.menu-locked,
html.menu-locked body {
  overflow: hidden;
}

/* ---- 表單和按鈕：高 48、圓角 12（設計稿 input／button Lg） ---- */
input,
select,
textarea {
  min-height: 48px;
  border-color: var(--neutral-300);
  border-radius: var(--radius-md);
  font-size: 16px; /* 小於 16px iPhone 點進去會自動放大畫面 */
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand-450);
  box-shadow: 0 0 0 1px var(--brand-450);
}

input::placeholder,
textarea::placeholder {
  color: var(--neutral-500);
}

input:disabled,
select:disabled,
textarea:disabled {
  background: var(--neutral-200);
  color: var(--neutral-400);
  border-color: transparent;
}

button,
a.button {
  min-height: 48px;
  border-radius: var(--radius-md);
  font-weight: 500;
}

button.secondary,
a.button {
  border-color: var(--brand-450);
  color: var(--brand-450);
}

button.primary {
  font-weight: 500;
}

button:disabled,
button.primary:disabled {
  opacity: 1;
  background: var(--neutral-200);
  border-color: transparent;
  color: var(--neutral-400);
}

button.link {
  min-height: 44px;
  color: var(--brand-450);
  font-weight: 500;
  text-decoration: none;
}

a {
  color: var(--brand-450);
}

.card {
  border-color: var(--neutral-300);
  border-radius: var(--radius-md);
  padding: 16px;
}

/* ---- 外框：上面一條 ☰＋央廚系統（設計稿 category-header） ---- */
.shell:not(.shell-solo) {
  display: block;
}

.m-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--header-height);
  padding: 0 16px;
  padding-left: max(16px, env(safe-area-inset-left));
  background: var(--neutral-0);
  border-bottom: 1px solid var(--neutral-300);
}

.m-header-title {
  padding-left: 8px;
  border-left: 1px solid var(--neutral-300);
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: var(--neutral-800);
  white-space: nowrap;
}

.m-menu-btn {
  width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  border: none;
  border-radius: var(--radius-md);
  background: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.m-menu-btn:hover {
  background: var(--neutral-100);
}

.m-menu-icon {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  width: 18px;
}

.m-menu-icon > span {
  display: block;
  height: 2px;
  border-radius: 1px;
  background: var(--neutral-800);
}

.m-menu-icon.is-close > span:nth-child(2) {
  width: 12px;
}

/* ---- 側邊欄 → 滿版選單（設計稿 side-menu，點 ☰ 從左邊滑出來） ---- */
.shell:not(.shell-solo) .sidebar {
  position: fixed;
  inset: 0;
  z-index: 40;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 0;
  overflow: hidden;
  background: var(--neutral-0);
  color: var(--neutral-800);
  transform: translateX(-100%);
  visibility: hidden;
  transition: transform 0.25s ease, visibility 0.25s;
}

.shell.menu-open .sidebar {
  transform: none;
  visibility: visible;
}

.m-menu-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  height: var(--header-height);
  padding: 0 16px;
  padding-left: max(16px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--neutral-300);
}

.shell:not(.shell-solo) .sidebar .brand {
  display: none;
}

.shell:not(.shell-solo) .sidebar nav {
  flex: 1;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  padding: 8px 0;
}

.shell:not(.shell-solo) .nav-group {
  flex-direction: column;
  gap: 0;
}

.shell:not(.shell-solo) .nav-group-title {
  display: block;
  padding: 8px 20px;
  font-size: 12px;
  line-height: 18px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--neutral-600);
}

.shell:not(.shell-solo) .sidebar nav a[data-nav] {
  margin: 0 8px;
  min-height: 48px;
  padding: 12px 32px;
  border: none;
  border-radius: var(--radius-md);
  color: var(--neutral-800);
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
}

.shell:not(.shell-solo) .sidebar nav a[data-nav]:hover {
  background: var(--neutral-100);
}

.shell:not(.shell-solo) .sidebar nav a[data-nav][aria-current="page"] {
  background: var(--brand-50);
  color: var(--brand-450);
  border: none;
  font-weight: 500;
}

.shell:not(.shell-solo) .sidebar a.badge {
  right: 40px;
}

.shell:not(.shell-solo) .sidebar a.badge:hover {
  box-shadow: none;
}

.badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  line-height: 20px;
}

/* 使用者：選單最下面，名字一行、改密碼／登出靠右（設計稿 side-menu-user） */
.shell:not(.shell-solo) .sidebar .user {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  flex: none;
  margin: 0;
  padding: 12px 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--neutral-300);
}

.shell:not(.shell-solo) .sidebar .user .avatar,
.shell:not(.shell-solo) .user-text {
  display: block;
}

.shell:not(.shell-solo) .sidebar .user .avatar {
  display: grid;
  width: 32px;
  height: 32px;
  background: var(--brand-100);
  color: var(--brand-450);
  font-weight: 500;
}

.shell:not(.shell-solo) .user-name {
  font-size: 16px;
  font-weight: 500;
  color: var(--neutral-800);
}

.shell:not(.shell-solo) .user-role {
  font-size: 12px;
  color: var(--neutral-600);
}

.shell:not(.shell-solo) .user-links {
  justify-content: flex-end;
  gap: 24px;
  font-size: 16px;
}

.shell:not(.shell-solo) .user-links a,
.shell:not(.shell-solo) .user-links button.link {
  min-height: 44px;
  color: var(--brand-450);
  font-weight: 500;
}

.shell:not(.shell-solo) .user-links a:hover,
.shell:not(.shell-solo) .user-links button.link:hover {
  color: var(--brand-500);
}

/* ---- 標題列：大標 24px；名字和日期已經在選單裡，這裡不重複（設計稿沒有） ---- */
.topbar {
  padding: 24px 16px 0;
}

.title-row h1 {
  font-size: 24px;
  line-height: 36px;
  color: var(--neutral-800);
}

.topbar-meta {
  margin-left: 0;
  width: 100%;
}

.topbar-meta > span:last-child {
  display: none;
}

#page-actions a {
  color: var(--brand-450);
  font-weight: 500;
}

.crumbs,
.crumbs a,
.back-link {
  color: var(--neutral-600);
}

.crumbs a:last-of-type,
.crumbs .here {
  color: var(--brand-450);
  font-weight: 500;
}

#view {
  padding: 16px 16px 32px;
}

/* =============================================================
   第 2 步：進貨入庫（設計稿 01／02 進貨入庫單、03 待確認；入庫紀錄照待確認的卡片）
   ============================================================= */

/* 手機不放說明文字（PJ 2026-11-10、Dennis 2026-11-12：之後寫進說明書） */
.lines-card .card-head .muted,
.receive .section-hint {
  display: none;
}

/* ---- 相機掃描：一顆滿版的綠色按鈕 ---- */
button.scan-field {
  display: none;
}

.scan-bar {
  margin-bottom: 0;
}

button.scan-button {
  flex: 1;
  min-height: 48px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--brand-450);
  color: var(--neutral-0);
  font-size: 16px;
  font-weight: 500;
}

button.scan-button:hover {
  background: var(--brand-500);
}

/* 廠區（拍照前先選，business-rules A0）：三顆平分一行；沒選時相機按鈕變灰 */
.site-pick {
  gap: 8px;
  margin-bottom: 10px;
}

.site-pick-buttons {
  flex: 1;
  flex-wrap: nowrap;
}

.site-pick-buttons button {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 6px 8px;
  border: 1px solid var(--brand-300);
  border-radius: var(--radius-md);
  background: var(--neutral-0);
  color: var(--brand-450);
  font-size: 16px;
  font-weight: 500;
}

.site-pick-buttons button[aria-pressed="true"] {
  border-color: var(--brand-450);
  background: var(--brand-450);
  color: var(--neutral-0);
}

.scan-bar.scan-off button.scan-button {
  background: var(--neutral-300);
  color: var(--neutral-0);
}

.scan-row {
  padding: 8px 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
}

.scan-row.tone-warn {
  padding: 8px;
  border-radius: var(--radius-md);
}

.scan-text {
  font-size: 15px;
  line-height: 22px;
}

/* ---- 整張單：提醒最上面，再來相機、單據資訊、品項；合計和按鈕固定在畫面最下面 ---- */
.receipt-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.receipt-form > * {
  margin: 0;
}

.receipt-form > .rc-banners {
  order: -1;
}

.receipt-form > .rc-banners:empty {
  display: none;
}

.receipt-form .card {
  padding: 16px;
}

.banner {
  border-radius: var(--radius-md);
}

.banner-warn {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.card-title {
  font-size: 20px;
  line-height: 30px;
  font-weight: 700;
  color: var(--neutral-800);
}

/* ---- 單據資訊：拍過照的單先收成一張小卡，按「修改」打開 ---- */
.rc-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.rc-head .card-title {
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
}

.rc-head.collapsible .rc-head-toggle {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 4px;
  border: none;
  background: none;
  color: var(--brand-450);
  font-weight: 500;
}

.rc-head.collapsible .rc-head-toggle::after {
  content: "";
  width: 7px;
  height: 7px;
  margin: -3px 0 0 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.rc-head.collapsible.head-open .rc-head-toggle::after {
  margin-top: 4px;
  transform: rotate(-135deg);
}

.rc-head.collapsible:not(.head-open) .rc-head-summary {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}

.rc-head.collapsible:not(.head-open) .rc-fields {
  display: none;
}

.rc-head-kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  line-height: 20px;
}

.rc-head-kv .k {
  color: var(--neutral-600);
  white-space: nowrap;
}

.rc-head-kv .v {
  text-align: right;
  color: var(--neutral-800);
}

.rc-head-kv .v.bad {
  color: var(--error-border);
}

.rc-fields {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ---- 品項明細：一個品項一張卡片 ----
   第一行：品名＋需確認＋刪除；第二行：數量、單位；第三行：單價、金額；
   原因寫在下面；「選品項」滿版；單號、效期、批號、儲區、規格收在「更多」 */
.lines-card {
  padding: 0 !important;
  border: none;
  background: none;
}

.lines-card .card-head {
  margin-bottom: 8px;
}

.lines-card .table-wrap {
  overflow: visible;
  border: none;
}

table.lines {
  display: block;
  min-width: 0;
}

table.lines thead {
  display: none;
}

table.lines tbody {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

table.lines tr.line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 40px;
  gap: 12px 8px;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-md);
  background: var(--neutral-0);
}

table.lines tr.line.flagged {
  border: 1px solid var(--error-border);
  border-left-width: 1px;
  background: var(--neutral-0);
}

table.lines tr.line td,
table.lines tr.flagged td,
table.lines tr.flagged td:first-child {
  display: block;
  grid-column: span 1;
  width: auto;
  padding: 0;
  border: none;
  background: none;
  box-shadow: none;
}

table.lines tr.line td[data-label]::before {
  content: attr(data-label);
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  line-height: 18px;
  color: var(--neutral-700);
}

/* 品名：第一行左邊兩格；不另外標「品項」兩個字 */
table.lines tr.line td.c-item_name {
  grid-column: 1 / 3;
  grid-row: 1;
}

table.lines tr.line td.c-item_name::before {
  display: none;
}

table.lines .item-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

table.lines .item-cell input {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  font-weight: 500;
}

/* 「!」換成設計稿的「需確認」標籤，點了一樣跳出原因 */
table.lines button.why {
  order: 2;
  flex: none;
  width: auto;
  min-height: 28px;
  height: 28px;
  padding: 0 6px;
  border: none;
  border-radius: var(--radius-xs);
  background: var(--warning-bg);
  color: var(--warning-text);
  font-size: 0;
}

table.lines button.why::after {
  content: "需確認";
  font-size: 12px;
  line-height: 18px;
  font-weight: 400;
}

/* 刪除：第一行右邊。「選品項」、刪除按鈕各自排進卡片裡 */
table.lines tr.line td.c-actions,
table.lines tr.line .line-actions {
  display: contents;
}

table.lines .line-actions .icon-button {
  grid-column: 3;
  grid-row: 1;
  align-self: center;
  width: 40px;
  min-height: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: var(--radius-md);
  background: none;
  color: var(--brand-450);
  font-size: 24px;
}

table.lines .line-actions .unmatched {
  grid-column: 1 / -1;
  min-height: 40px;
  border-color: var(--brand-450);
  color: var(--brand-450);
}

/* 選品項：還沒對應品項＝必填，跟其他要填的格子一樣紅框（Dennis 2026-11-24） */
table.lines .line-actions .unmatched:not(:disabled) {
  border-color: var(--error-border);
  box-shadow: 0 0 0 1px var(--error-border);
  color: var(--error-text);
}

table.lines .line-actions [hidden] {
  display: none !important;
}

/* 數量、單位一行；單價、金額一行（Dennis 2026-11-12：單價要自己一格） */
table.lines tr.line td.c-quantity { grid-column: 1; }
table.lines tr.line td.c-unit { grid-column: 2 / 4; }
table.lines tr.line td.c-unit_price { grid-column: 1; }
table.lines tr.line td.c-amount { grid-column: 2 / 4; }

table.lines tr.line td input,
table.lines tr.line td select {
  width: 100%;
  max-width: none;
  min-height: 48px;
  border-radius: var(--radius-md);
}

table.lines select.needs-check,
table.lines input.needs-check {
  border-color: var(--error-border);
  box-shadow: 0 0 0 1px var(--error-border);
  background: var(--neutral-0);
}

/* 欄高統一 48（Dennis 2026-11-19 iPhone 實測：單位、儲區的下拉比較矮，有效期限比較高又比較寬）：
   iPhone Safari 的下拉不吃 min-height、日期格子有自己的高度和最小寬度，所以直接定高度、拿掉日期的內建外觀 */
table.lines tr.line td input:not([type="checkbox"]),
table.lines tr.line td select {
  box-sizing: border-box;
  display: block;
  min-width: 0;
  height: 48px;
}

table.lines tr.line td input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  background: var(--neutral-0);
  text-align: left;
}

table.lines tr.line td input[type="date"]::-webkit-date-and-time-value {
  text-align: left;
}

/* iPhone／iPad Safari：下拉不拿掉內建外觀就不吃 height，日期格子有自己的最小寬度（Dennis 2026-11-20 實機仍不一樣高、日期比較寬）。
   下拉換成自己畫的箭頭；日期限制在格子寬度內；單號（唯讀）也畫成跟其他格一樣的格子 */
table.lines tr.line td select {
  -webkit-appearance: none;
  appearance: none;
  padding-left: 12px;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%236b7068' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

table.lines tr.line td input[type="date"] {
  width: 100%;
  max-width: 100%;
  line-height: normal;
}

table.lines tr.line td input[type="date"]:disabled,
table.lines tr.line td select:disabled {
  background-color: var(--neutral-200, #eceeec);
}

table.lines tr.line td .slip-no {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  height: 48px;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-md, 12px);
  background: var(--neutral-200, #eceeec);
  color: var(--neutral-700, #555);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

table.lines tr.line td {
  min-width: 0;
}

/* 收起來的品項（不用人工確認的）：一行品名、一行「數量 單位 × 單價 = 金額」，點了打開（Dennis 2026-11-19） */
table.lines tr.line.compact {
  padding: 0;
}

table.lines tr.line.compact > td {
  display: none !important;
}

/* 打開的卡片不出現收起來那一行（卡片的 td 規則是 display: block，要蓋過去） */
table.lines tr.line:not(.compact) > td.c-compact {
  display: none !important;
}

table.lines tr.line.compact > td.c-compact {
  display: block !important;
  grid-column: 1 / -1;
}

table.lines button.line-compact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 0;
  padding: 16px;
  border: none;
  background: none;
  text-align: left;
  color: var(--neutral-800);
}

table.lines button.line-compact::after {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--neutral-600);
  border-bottom: 2px solid var(--neutral-600);
  transform: rotate(-45deg);
}

table.lines .lc-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

table.lines .lc-name {
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
}

table.lines .lc-nums {
  font-size: 14px;
  line-height: 20px;
  color: var(--neutral-600);
  font-variant-numeric: tabular-nums;
}

table.lines button.line-collapse {
  margin-left: 24px;
  min-height: 40px;
  padding: 0;
  border: none;
  background: none;
  color: var(--neutral-600);
  font-size: 15px;
}

/* 原因：紅字放卡片最上面，先看要確認什麼（Dennis 2026-11-19）；有紅字時品名、刪除往下一行 */
table.lines tr.line td.c-hint {
  grid-column: 1 / -1;
  grid-row: 1;
}

table.lines tr.line:has(.line-hint:not([hidden])) td.c-item_name,
table.lines tr.line:has(.line-hint:not([hidden])) .line-actions .icon-button {
  grid-row: 2;
}

table.lines .line-hint {
  font-size: 14px;
  line-height: 20px;
  color: var(--error-border);
}

table.lines tr.line td.c-hint:has(.line-hint[hidden]) {
  display: none;
}

/* 「更多」：收起來時只看到這顆文字按鈕 */
table.lines tr.line td.c-slip_no,
table.lines tr.line td.c-expiry_date,
table.lines tr.line td.c-batch_no,
table.lines tr.line td.c-location,
table.lines tr.line td.c-spec {
  display: none;
}

table.lines tr.line.more-open td.c-slip_no,
table.lines tr.line.more-open td.c-expiry_date,
table.lines tr.line.more-open td.c-batch_no,
table.lines tr.line.more-open td.c-location,
table.lines tr.line.more-open td.c-spec {
  display: block;
}

table.lines tr.line td.c-slip_no,
table.lines tr.line td.c-batch_no,
table.lines tr.line td.c-spec { grid-column: 1; }
table.lines tr.line td.c-expiry_date,
table.lines tr.line td.c-location { grid-column: 2 / 4; }

table.lines .slip-no {
  display: flex;
  align-items: center;
  min-height: 48px;
  color: var(--neutral-700);
}

table.lines tr.line td.c-more {
  grid-column: 1 / -1;
  order: 99;
}

table.lines button.line-more {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0;
  border: none;
  background: none;
  color: var(--brand-450);
  font-size: 15px;
  font-weight: 500;
  text-align: left;
}

table.lines button.line-more::after {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  margin: -3px 0 0 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

table.lines tr.line.more-open button.line-more::after {
  margin-top: 4px;
  transform: rotate(-135deg);
}

/* 沒有品項時的那一行 */
table.lines tbody tr:not(.line) {
  display: block;
}

table.lines tbody tr:not(.line) td {
  display: block;
  padding: 24px 12px;
  border: 1px dashed var(--neutral-300);
  border-radius: var(--radius-md);
  text-align: center;
  color: var(--neutral-600);
}

/* 手動新增品項：外框綠色的按鈕 */
.add-line {
  margin-top: 8px;
}

button.add-line-open {
  min-height: 48px;
  border: 1px solid var(--brand-450);
  border-radius: var(--radius-md);
  background: var(--neutral-0);
  color: var(--brand-450);
  font-weight: 500;
}

.add-line {
  flex-wrap: wrap;
}

.add-line input {
  flex: 1 1 100%;
}

.add-line button {
  flex: 1;
}

/* 合計＋取消／確認入庫：固定在畫面最下面（設計稿的置底按鈕列） */
.rc-footer {
  position: sticky;
  bottom: 0;
  z-index: 10;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  margin: 0 -16px -32px;
  padding: 12px 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  background: var(--neutral-0);
  box-shadow: 0 -1px 0 var(--neutral-300);
}

.rc-summary {
  font-size: 14px;
  line-height: 20px;
  color: var(--neutral-800);
}

.rc-footer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.rc-footer-actions button {
  flex: 1;
}

.rc-footer-actions button {
  padding: 8px 10px;
}

/* 跳出來的小通知（例如「已確認入庫」）：放到畫面上方、淺色、前面打勾。
   原本在右下角深綠色，剛好壓在置底按鈕上，看起來像一顆按鈕（Dennis 2026-11-19） */
body:has(.rc-footer) #toasts {
  top: calc(var(--header-height) + 8px);
  right: 16px;
  bottom: auto;
  left: 16px;
}

body:has(.rc-footer) .toast {
  max-width: none;
  padding: 12px 16px;
  border: 1px solid var(--brand-450);
  border-radius: var(--radius-md);
  background: var(--brand-50);
  color: var(--brand-500);
  font-size: 15px;
  line-height: 22px;
}

body:has(.rc-footer) .toast-info::before {
  content: "✓ ";
  font-weight: 700;
}

body:has(.rc-footer) .toast-error {
  border-color: var(--error-border);
  background: var(--error-bg);
  color: var(--error-border);
}

/* ---- 待確認、入庫紀錄：每一列一張卡片，欄名在左、值在右 ---- */
.receive table.list,
.history table.list {
  display: block;
  min-width: 0;
}

.receive .table-wrap,
.history .table-wrap {
  overflow: visible;
  border: none;
}

.receive table.list thead,
.history table.list thead {
  display: none;
}

.receive table.list tbody,
.history table.list tbody {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.receive table.list tr,
.history table.list tr {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-md);
  background: var(--neutral-0);
}

.receive table.list td,
.history table.list td {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 0;
  border: none;
  font-size: 14px;
  line-height: 20px;
  text-align: right;
  white-space: normal;
  background: none;
}

.receive table.list td[data-label]::before,
.history table.list td[data-label]::before {
  content: attr(data-label);
  color: var(--neutral-600);
  text-align: left;
  white-space: nowrap;
}

/* 卡片標題：供應商（設計稿 03 的 list-card-title） */
.receive table.list td.c-title,
.history table.list td.c-title {
  order: -2;
  justify-content: flex-start;
  margin-bottom: 4px;
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
  text-align: left;
}

.receive table.list td.c-title a {
  color: var(--neutral-800);
  text-decoration: none;
}

.history table.list td.c-status {
  order: -1;
  justify-content: flex-start;
  margin: -4px 0 4px;
}

.receive table.list td.c-zero {
  display: none;
}

.tag {
  border-radius: var(--radius-xs);
}

.tag-warn {
  background: var(--warning-bg);
  color: var(--warning-text);
}

/* 待確認最下面的「＋ 新增入庫單」 */
.m-bottom-bar {
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: block;
  margin: 16px -16px -32px;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  background: var(--neutral-0);
  box-shadow: 0 -1px 0 var(--neutral-300);
}

.m-bottom-bar a.button {
  display: flex;
  justify-content: center;
  width: 100%;
  border: none;
  background: var(--brand-450);
  color: var(--neutral-0);
}

/* 待確認：標題旁的「＋ 新的進貨入庫單」改由最下面的按鈕負責 */
#view:has(.m-bottom-bar) ~ * #page-actions,
.main:has(.m-bottom-bar) #page-actions {
  display: none;
}

/* 待確認、入庫紀錄：外面那層大卡片拿掉，卡片直接排在頁面上（設計稿 03） */
.receive > .card,
.history.card {
  padding: 0;
  border: none;
  background: none;
}

.receive > .card + .card {
  margin-top: 24px;
}

.receive .section-head h2 {
  font-size: 20px;
  line-height: 30px;
}

/* 卡片上的品名看起來像標題（設計稿 02）；點一下還是可以改 */
table.lines .item-cell input:not(:focus):not(.needs-check) {
  min-height: 40px;
  padding: 0;
  border-color: transparent;
  background: none;
  box-shadow: none;
}

/* 卡片：整張卡片變色，不是每一格各自變色（手機點過之後會留著 hover） */
.receive table.list tr.clickable:hover td,
.history table.list tr.clickable:hover td {
  background: none;
}

.receive table.list tr.clickable:active,
.history table.list tr.clickable:active {
  background: var(--neutral-100);
}

/* =============================================================
   雜項支出 › 輸入（新增支出 #/misc/new，也是修改那一筆的頁）：照設計稿 06 新增支出
   - 分頁：底線式大字（設計稿 tabs-full），放不下左右滑
   - 不用卡片框，欄位名 16px 粗一點，格子之間 16px
   - 照片：拍照／上傳兩個按鈕並排；拍好的照片 100×100 小方塊（設計稿 upload）
     拍照仍放最上面：拍了會幫忙填下面的格子（Dennis 2026-11-10 決定，設計稿放在下面）
   - 說明文字拿掉（Dennis 2026-11-12：手機不放說明，之後放說明書）；算出來的數字（每月多少）照留
   - 「儲存」固定在最下面（設計稿 bottom-bar）
   只套用在 .misc-new（雜項支出的輸入表單）；營業成本月結帳單也用 .misc-entry 等 class，不受影響。
   欄位一個都沒少：輸入人員、沖每月預估、攤提都在（設計稿沒畫）。
   ============================================================= */
#view:has(> .misc-new) > .pill-tabs {
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 0;
  margin: 0 -16px 8px;
  padding: 0 16px;
  border-bottom: 1px solid var(--neutral-300);
  scrollbar-width: none;
}

#view:has(> .misc-new) > .pill-tabs::-webkit-scrollbar {
  display: none;
}

#view:has(> .misc-new) > .pill-tabs .pill {
  position: relative;
  flex: none;
  min-height: 50px;
  padding: 10px 8px;
  border: none;
  border-radius: 0;
  background: none;
  color: var(--neutral-600);
  font-size: 20px;
  line-height: 30px;
  font-weight: 700;
}

#view:has(> .misc-new) > .pill-tabs .pill.active {
  color: var(--neutral-800);
}

#view:has(> .misc-new) > .pill-tabs .pill.active::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 0;
  height: 3px;
  border-radius: 2px 2px 0 0;
  background: var(--brand-450);
}

.misc-new {
  border: none;
  border-radius: 0;
  padding: 0;
  background: none;
  box-shadow: none;
}

/* 新增時不用再寫一次「輸入支出」（分頁已經寫了）；修改時留著「修改支出」 */
.misc-new > h2 {
  display: none;
}

.misc-new.is-edit > h2 {
  display: block;
  margin: 8px 0 0;
  font-size: 20px;
  line-height: 30px;
}

.misc-new .misc-entry-grid {
  gap: 16px;
  margin-top: 16px;
}

.misc-new .misc-stack {
  gap: 16px;
}

.misc-new .misc-field {
  gap: 8px;
  margin: 0; /* 全站 label 有上下留白，這裡用 gap 排就好 */
}

.misc-new .misc-field > span:first-child,
.misc-new .misc-field > label:first-child {
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
  color: var(--neutral-800);
}

.misc-new .misc-field .req {
  color: var(--error-text);
}

.misc-new .misc-field select,
.misc-new .misc-field input:not([type="radio"]):not([type="checkbox"]) {
  width: 100%;
  padding-left: 16px;
}

.misc-new .misc-amort-row input,
.misc-new .misc-amort-row.misc-bill-row input {
  flex: 1;
  width: auto;
}

/* 照片 */
.misc-new .misc-photo {
  min-height: 0;
  align-items: stretch;
  gap: 8px;
  padding: 0;
  border: none;
  background: none;
}

.misc-new .misc-photo > .misc-cam,
.misc-new .misc-photo > span {
  display: none;
}

.misc-new .misc-photo-btns {
  gap: 12px;
}

.misc-new .misc-photo-btns > button {
  flex: 1;
}

.misc-new .misc-thumbs {
  justify-content: flex-start;
  gap: 8px;
}

.misc-new .misc-thumb {
  position: relative;
  width: 100px;
  height: 100px;
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--neutral-100);
}

.misc-new .misc-thumb a {
  display: block;
  width: 100%;
  height: 100%;
}

.misc-new .misc-thumb img {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: cover;
  border: none;
  border-radius: 0;
}

/* 「移除」變成右上角的小 ✕（點的範圍 32×32） */
.misc-new .misc-thumb > button.link {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  font-size: 0;
  background: none;
}

.misc-new .misc-thumb > button.link::before {
  content: "✕";
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin: 5px;
  border-radius: 50%;
  background: rgba(12, 14, 31, 0.6);
  color: #fff;
  font-size: 12px;
  line-height: 1;
}

/* 攤提月數沒填時的說明拿掉；填了算出來的「每月多少、到哪個月」照留 */
.misc-new .misc-field:has(#m-amort:placeholder-shown) .misc-amort-hint {
  display: none;
}

.misc-new .misc-amort-hint {
  font-size: 14px;
  line-height: 20px;
}

/* 儲存固定在畫面最下面；錯誤訊息貼在它上面，捲到哪都看得到 */
.misc-new > .form-error {
  position: sticky;
  bottom: calc(80px + env(safe-area-inset-bottom));
  z-index: 5;
  margin: 16px 0 0;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--error-bg);
  color: var(--error-text);
}

.misc-new .misc-entry-foot {
  position: sticky;
  bottom: 0;
  z-index: 5;
  gap: 12px;
  margin: 16px -16px -32px;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  border-top: none;
  background: var(--neutral-0);
  box-shadow: 0 -1px 0 var(--neutral-300);
}

.misc-new .misc-entry-foot > button,
.misc-new .misc-entry-foot > a {
  flex: 1;
}

.misc-new .misc-entry-foot > a.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border: 1px solid var(--brand-450);
  border-radius: var(--radius-md);
  color: var(--brand-450);
  font-weight: 500;
  text-decoration: none;
}

/* 跳出來的小通知不要蓋住「儲存」 */
body:has(.misc-new) #toasts {
  bottom: calc(96px + env(safe-area-inset-bottom));
}

/* =============================================================
   雜項支出 › 支出明細（#/misc）：照設計稿 05 雜項支出 明細（Dennis 2026-11-15 選「只改支出明細」）
   - 分頁跟輸入頁一樣是底線式大字
   - 月份、類別兩格並排；「＋ 新增支出」固定在畫面最下面
   - 依類別／依單據收起來，點了才打開（misc.js 手機才畫成 <details>）
   - 一筆一行：品項（標籤）／日期・類別・單據，右邊金額 ›；點整行＝修改
   - 類別下拉、刪除、備註、照片都還在（明細可以直接改類別，Dennis 2026-11-05）
   只套用在 .misc-history（雜項支出明細）。
   ============================================================= */
#view:has(> .misc-history) > .pill-tabs {
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 0;
  margin: 0 -16px 8px;
  padding: 0 16px;
  border-bottom: 1px solid var(--neutral-300);
  scrollbar-width: none;
}

#view:has(> .misc-history) > .pill-tabs::-webkit-scrollbar {
  display: none;
}

#view:has(> .misc-history) > .pill-tabs .pill {
  position: relative;
  flex: none;
  min-height: 50px;
  padding: 10px 8px;
  border: none;
  border-radius: 0;
  background: none;
  color: var(--neutral-600);
  font-size: 20px;
  line-height: 30px;
  font-weight: 700;
}

#view:has(> .misc-history) > .pill-tabs .pill.active {
  color: var(--neutral-800);
}

#view:has(> .misc-history) > .pill-tabs .pill.active::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 0;
  height: 3px;
  border-radius: 2px 2px 0 0;
  background: var(--brand-450);
}

/* 最下面留位置給固定的「＋ 新增支出」 */
#view:has(> .misc-history) {
  padding-bottom: calc(112px + env(safe-area-inset-bottom));
}

.misc-history {
  margin-top: 16px;
  border: none;
  border-radius: 0;
  padding: 0;
  background: none;
  box-shadow: none;
}

.misc-history .misc-filter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.misc-history .misc-filter-row input,
.misc-history .misc-filter-row select {
  width: 100%;
  padding-left: 16px;
}

/* iPhone Safari 的月份格子有自己的最小寬度、字置中，會蓋到旁邊的類別（Dennis 2026-11-15 實測）：
   拿掉內建外觀、允許縮窄、字靠左，跟類別一樣高 */
.misc-history .misc-filter-row input[type="month"] {
  display: block;
  min-width: 0;
  max-width: 100%;
  height: 48px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--neutral-0);
  text-align: left;
}

.misc-history .misc-filter-row input[type="month"]::-webkit-date-and-time-value {
  text-align: left;
}

.misc-history .misc-filter-row > * {
  min-width: 0;
}

/* 「＋ 新增支出」：一條白底固定在最下面（設計稿 bottom-bar） */
.misc-history::after {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  height: calc(80px + env(safe-area-inset-bottom));
  background: var(--neutral-0);
  box-shadow: 0 -1px 0 var(--neutral-300);
}

.misc-history .misc-filter-row > .primary {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 5;
  margin: 0;
}

body:has(.misc-history) #toasts {
  bottom: calc(96px + env(safe-area-inset-bottom));
}

.misc-history .cost-total {
  margin: 16px 0;
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
}

.misc-history .cost-total b {
  font-size: 16px;
  font-weight: 500;
}

/* 依類別／依單據：收合（設計稿 accordion） */
.misc-history .cost-breakdowns {
  display: block;
  margin: 0;
  border-top: 1px solid var(--neutral-300);
}

.misc-history .misc-acc {
  border-bottom: 1px solid var(--neutral-300);
}

.misc-history .misc-acc > summary {
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
  padding: 16px 40px 16px 0;
  list-style: none;
  cursor: pointer;
}

.misc-history .misc-acc > summary::-webkit-details-marker {
  display: none;
}

.misc-history .misc-acc > summary::after {
  content: "";
  position: absolute;
  right: 8px;
  top: 50%;
  width: 9px;
  height: 9px;
  margin-top: -7px;
  border-right: 2px solid var(--neutral-800);
  border-bottom: 2px solid var(--neutral-800);
  transform: rotate(45deg);
  transition: transform 0.2s;
}

.misc-history .misc-acc[open] > summary::after {
  margin-top: -2px;
  transform: rotate(-135deg);
}

.misc-acc-title {
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
  color: var(--neutral-800);
}

.misc-acc-desc {
  font-size: 14px;
  line-height: 20px;
  color: var(--neutral-600);
}

.misc-history .misc-acc table {
  margin: 0 0 12px;
}

.misc-history .misc-acc td {
  padding: 4px 0;
  border: none;
  font-size: 14px;
  color: var(--neutral-600);
}

.misc-history .misc-acc td.num {
  color: var(--neutral-800);
  font-weight: 500;
}

/* 「明細」小標、「類別可以直接在下面選」說明：手機不放 */
.misc-history .cost-bills-title,
.misc-history .misc-cat-hint {
  display: none;
}

.misc-history .misc-savebar {
  margin: 12px 0;
}

/* 一筆一行（設計稿 list-item） */
.misc-history .table-wrap::before {
  display: none;
}

.misc-history .table-wrap:has(> table.misc-list) {
  overflow: visible;
  border: none;
  border-radius: 0;
  -webkit-mask-image: none;
  mask-image: none;
}

.misc-history table.misc-list,
.misc-history table.misc-list tbody {
  display: block;
  width: 100%;
}

.misc-history table.misc-list thead {
  display: none;
}

.misc-history table.misc-list td {
  padding: 0;
  border: none;
}

.misc-history table.misc-list tr {
  position: relative;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto 16px; /* 日期｜單據｜類別｜金額、刪除｜› */
  gap: 4px 0;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--neutral-300);
}

.misc-history table.misc-list td {
  font-size: 14px;
  line-height: 20px;
  color: var(--neutral-600);
}

/* 品項＋標籤 */
.misc-history table.misc-list td:nth-child(3) {
  grid-column: 1 / 4;
  grid-row: 1;
  padding-right: 12px;
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
  color: var(--neutral-800);
}

.misc-history table.misc-list .misc-amort-badge,
.misc-history table.misc-list .misc-est-badge {
  margin-left: 6px;
  padding: 0 6px;
  border-radius: var(--radius-xs);
  background: var(--brand-100);
  color: var(--brand-450);
  font-size: 12px;
  line-height: 20px;
  font-weight: 400;
}

/* 金額 */
.misc-history table.misc-list td:nth-child(4) {
  grid-column: 4;
  grid-row: 1;
  justify-self: end;
  padding-left: 12px;
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
  color: var(--neutral-800);
}

/* 第二行：日期・單據・類別（類別是下拉，放最後，寬度用剩下的） */
.misc-history table.misc-list td:nth-child(1) {
  grid-column: 1;
  grid-row: 2;
  white-space: nowrap;
}

.misc-history table.misc-list td:nth-child(5) {
  grid-column: 2;
  grid-row: 2;
  text-align: left;
  white-space: nowrap;
}

.misc-history table.misc-list td:nth-child(2) {
  grid-column: 3;
  grid-row: 2;
  position: relative;
  z-index: 2;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.misc-history table.misc-list td:nth-child(2)::before,
.misc-history table.misc-list td:nth-child(5)::before {
  content: "・";
}

/* 類別下拉看起來像字，旁邊一個小 ▾，點了一樣能改 */
.misc-history table.misc-list select.misc-cat-pick {
  min-width: 0;
  width: auto;
  field-sizing: content; /* 寬度跟著選到的字；不支援的手機就用剩下的寬度 */
  max-width: 100%;
  min-height: 0;
  height: 28px;
  padding: 0 16px 0 2px;
  border: none;
  border-radius: var(--radius-xs);
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%235e5f6b' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 3px center;
  color: var(--neutral-600);
  font-size: 14px;
  -webkit-appearance: none;
  appearance: none;
}

.misc-history table.misc-list select.misc-cat-pick.changed {
  background-color: var(--warning-bg);
  color: var(--warning-text);
}

/* 備註、照片：有才出現，第三行 */
.misc-history table.misc-list td:nth-child(6) {
  grid-column: 1 / 6;
  white-space: normal;
  grid-row: 3;
  position: relative;
  z-index: 2;
}

.misc-history table.misc-list td:nth-child(6):empty {
  display: none;
}

/* 修改／刪除：整行點一下＝修改（金額右邊一個 ›）；刪除留一個小字在金額下面 */
.misc-history table.misc-list td:nth-child(7) {
  grid-column: 4 / 6;
  grid-row: 2;
  justify-self: end;
}

.misc-history table.misc-list td:nth-child(7) button.link:first-child {
  position: static;
  min-height: 0;
  font-size: 0;
}

.misc-history table.misc-list td:nth-child(7) button.link:first-child::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

.misc-history table.misc-list tr:has(td:nth-child(7) button.link:first-child)::after {
  content: "";
  grid-column: 5;
  grid-row: 1;
  justify-self: end;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--neutral-800);
  border-top: 2px solid var(--neutral-800);
  transform: rotate(45deg);
}

.misc-history table.misc-list td:nth-child(7) button.danger,
.misc-history table.misc-list td:nth-child(7) a {
  position: relative;
  z-index: 2;
  min-height: 32px;
  padding: 0 0 0 12px;
  font-size: 14px;
}

/* =============================================================
   營業成本 › 月結帳單（#/cost/bills）：照設計稿 12「營業成本 月結帳單」
   - 分頁：底線式大字；「輸入月結帳單」分頁拿掉，改用最下面固定的「＋ 輸入帳單」
   - 「11 月對帳」小標＋月份在同一行；上個月／下個月按鈕拿掉（月份格子可以直接選）
   - 兩張數字卡：帳單合計（幾家已輸入）、進貨入庫合計（幾家供應商）
   - 一家供應商一張卡：名字＋標籤（相符／有差額／還沒輸入帳單）＋ ›；帳單金額、入庫合計、差額、付款日、備註
     點卡片在下面打開帳單和出貨單一張一張的核對（跟電腦點一列一樣），cost-bills.js phoneCard()
   - 說明文字拿掉
   電腦、iPad 照舊是表格（.bill-m-only 在 app.css 藏起來）。
   ============================================================= */
#view:has(.bill-month-bar) > .pill-tabs {
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 0;
  margin: 0 -16px 8px;
  padding: 0 16px;
  border-bottom: 1px solid var(--neutral-300);
  scrollbar-width: none;
}

#view:has(.bill-month-bar) > .pill-tabs::-webkit-scrollbar {
  display: none;
}

#view:has(.bill-month-bar) > .pill-tabs .pill {
  position: relative;
  flex: none;
  min-height: 50px;
  padding: 10px 8px;
  border: none;
  border-radius: 0;
  background: none;
  color: var(--neutral-600);
  font-size: 20px;
  line-height: 30px;
  font-weight: 700;
}

#view:has(.bill-month-bar) > .pill-tabs .pill.active {
  color: var(--neutral-800);
}

#view:has(.bill-month-bar) > .pill-tabs .pill.active::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 0;
  height: 3px;
  border-radius: 2px 2px 0 0;
  background: var(--brand-450);
}

/* 第一個分頁是「輸入月結帳單」：設計稿用最下面的按鈕 */
#view:has(.bill-month-bar) > .pill-tabs .pill:first-child {
  display: none;
}

/* 標題旁的「＋ 拍進貨單」設計稿沒有（兩頁都拿掉） */
.main:has(.bill-month-bar) #page-actions,
.main:has(.bill-entry) #page-actions {
  display: none;
}

.history:has(.bill-month-bar) {
  margin-top: 16px;
}

.bill-month-bar {
  flex-wrap: nowrap;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 16px;
}

.bill-month-bar > button {
  display: none;
}

.bill-month-bar > .bill-m-title {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-size: 20px;
  line-height: 30px;
  font-weight: 700;
  color: var(--neutral-800);
}

/* 月份：160 寬、字靠左（iPhone 的月份格子有自己的最小寬度、字置中） */
.bill-month-bar > input[type="month"] {
  display: block;
  flex: 0 0 160px;
  width: 160px;
  min-width: 0;
  height: 48px;
  padding: 0 16px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--neutral-0);
  text-align: left;
}

.bill-month-bar > input[type="month"]::-webkit-date-and-time-value {
  text-align: left;
}

/* 電腦版的合計一行、表格、說明：手機換成下面的數字卡和供應商卡 */
.history:has(.bill-month-bar) .cost-total,
.history:has(.bill-month-bar) .table-wrap:has(> table.bills-month),
.history:has(.bill-month-bar) .bills-month-note {
  display: none;
}

/* 兩張數字卡（設計稿 kpi） */
.bill-m-kpis {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.bill-m-kpi {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 16px;
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-md);
  background: var(--neutral-0);
}

.bill-m-kpi .k,
.bill-m-kpi .d {
  font-size: 12px;
  line-height: 18px;
  color: var(--neutral-600);
}

.bill-m-kpi .v {
  font-size: 20px;
  line-height: 30px;
  font-weight: 700;
  color: var(--neutral-800);
  font-variant-numeric: tabular-nums;
}

/* 供應商卡（設計稿 list-card） */
.bill-m-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bill-m-card {
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-md);
  background: var(--neutral-0);
  overflow: hidden;
}

.bill-m-main {
  display: block;
  padding: 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.bill-m-main:active {
  background: var(--neutral-100);
}

.bill-m-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bill-m-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
  color: var(--neutral-800);
}

.bill-m-name .tag {
  display: inline-flex;
  align-items: center;
  height: 28px;
  margin: 0;
  padding: 0 4px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  line-height: 18px;
  font-weight: 400;
  white-space: normal;
}

.tag-m-success {
  background: var(--success-bg);
  color: var(--success-text);
}

.tag-m-error {
  background: var(--error-bg);
  color: var(--error-text);
}

.tag-m-info {
  background: var(--brand-50);
  color: var(--brand-450);
}

/* › ；打開時轉向下 */
.bill-m-chev {
  flex: none;
  width: 24px;
  height: 24px;
  position: relative;
}

.bill-m-chev::before {
  content: "";
  position: absolute;
  top: 7px;
  left: 6px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--neutral-800);
  border-top: 2px solid var(--neutral-800);
  transform: rotate(45deg);
}

.bill-m-card.open .bill-m-chev::before {
  top: 5px;
  left: 8px;
  transform: rotate(135deg);
}

.bill-m-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--neutral-300);
}

.bill-m-row {
  display: flex;
  gap: 8px;
  font-size: 16px;
  line-height: 24px;
}

.bill-m-row .k {
  flex: none;
  width: 120px;
  color: var(--neutral-600);
}

.bill-m-row .v {
  flex: 1;
  min-width: 0;
  text-align: right;
  font-weight: 500;
  color: var(--neutral-800);
  font-variant-numeric: tabular-nums;
}

.bill-m-row .v.bad-text {
  color: var(--error-text);
}

/* 點開的核對明細 */
.bill-m-detail {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--neutral-300);
  background: var(--neutral-100);
  font-size: 14px;
  line-height: 20px;
}

.bill-m-detail p {
  margin: 0 0 8px;
}

.bill-m-detail .table-wrap {
  overflow: visible;
  border: none;
}

/* 最下面固定的「＋ 輸入帳單」 */
.history .bill-m-new {
  margin-top: 16px;
}

/* =============================================================
   營業成本 › 輸入月結帳單（#/cost/bills/new，?id= 是修改）：照設計稿 13「輸入月結帳單」
   - 不用分頁、不用卡片框；大標「輸入月結帳單／修改月結帳單」，下面一條淡綠提醒（設計稿的字）
   - 欄位照設計稿的順序：供應商、算在哪個月、總計（帳單金額）、付款日、備註；
     設計稿沒畫、但核對要用的欄位排在後面：對帳期間、未稅、稅額、發票號碼、輸入人員、帳單上的出貨單
   - 照片：100×100 小方塊＋一格「⊕」加照片（設計稿 upload）；點小方塊放大看。
     照片仍在最上面：上傳後系統會讀照片把格子先填好（Dennis 2026-11-09 自動讀；11-10、11-16 照片放最上面）
   - 說明文字拿掉；照片讀好的黃色提示、出貨單合計照留
   - 取消／儲存固定在最下面（設計稿 bottom-bar）
   ============================================================= */
#view:has(> .bill-entry) > .pill-tabs,
.main:has(.bill-entry) .topbar {
  display: none;
}

.bill-entry {
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: none;
  box-shadow: none;
}

.bill-entry > h2 {
  margin: 8px 0 16px;
  font-size: 24px;
  line-height: 36px;
  font-weight: 700;
  color: var(--neutral-800);
}

/* 提醒（設計稿 notice-info：淡綠底、左邊 ⓘ） */
.bill-entry > .bill-m-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--brand-50);
  color: var(--neutral-800);
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
}

.bill-entry > .bill-m-notice::before {
  content: "";
  flex: none;
  width: 24px;
  height: 24px;
  background: var(--brand-450);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v5M12 8v.5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v5M12 8v.5'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* 照片讀好了的提示框：設計稿 notice-warning 的淡橘色（Dennis 2026-11-19）；讀出來的格子還是黃色 */
.bill-entry .bill-read-note {
  margin: 0 0 16px;
  padding: 16px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--warning-bg);
  color: var(--warning-text);
  font-size: 14px;
  line-height: 20px;
}

.bill-entry .misc-entry-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.bill-entry .misc-stack {
  gap: 16px;
}

.bill-entry .misc-field {
  gap: 8px;
  margin: 0;
}

.bill-entry .misc-field > span:first-child {
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
  color: var(--neutral-800);
}

.bill-entry .misc-field .req {
  color: var(--error-text);
}

.bill-entry .bill-hint,
.bill-entry .bill-slip-help {
  display: none;
}

.bill-entry .misc-field select,
.bill-entry .misc-field input:not([type="radio"]):not([type="checkbox"]):not([type="file"]) {
  width: 100%;
  padding-left: 16px;
}

.bill-entry .misc-amort-row input {
  flex: 1;
  width: auto;
}

/* 欄位順序：設計稿有的在前，其他照原本的順序排在後面 */
.bill-entry .bill-money {
  display: contents;
}

.bill-entry .misc-stack > :has(#b-sup) { order: 1; }
.bill-entry .misc-stack > :has(#b-month) { order: 2; }
.bill-entry .bill-money > :has(#b-total) { order: 3; }
.bill-entry .misc-stack > :has(#b-paid) { order: 4; }
.bill-entry .misc-stack > :has(#b-note) { order: 5; }
.bill-entry .misc-stack > .bill-period { order: 6; }
.bill-entry .bill-money > :has(#b-sub) { order: 7; }
.bill-entry .bill-money > :has(#b-tax) { order: 8; }
.bill-entry .misc-stack > :has(#b-inv) { order: 9; }
.bill-entry .misc-stack > :has(#b-by) { order: 10; }
.bill-entry .misc-stack > :has(.bill-slips) { order: 11; }

/* 照片：最上面，100×100 小方塊＋⊕ */
.bill-entry .bill-photo-col {
  position: static;
  order: -1;
}

.bill-entry .bill-photo {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
}

.bill-entry .bill-photo > .misc-photo {
  display: contents;
}

.bill-entry .bill-photo .misc-cam,
.bill-entry .bill-photo > .misc-photo > span {
  display: none;
}

.bill-entry .bill-photo-big {
  display: none;
  order: 10;
  flex: 1 0 100%;
}

.bill-entry .bill-photo[data-big="1"] .bill-photo-big {
  display: block;
}

.bill-entry .bill-photo-big img {
  max-height: 70vh;
  border-color: var(--neutral-300);
  border-radius: var(--radius-md);
}

.bill-entry .bill-photo-strip {
  display: contents;
}

.bill-entry .bill-photo .misc-thumb {
  position: relative;
  width: 100px;
  height: 100px;
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--neutral-100);
}

.bill-entry .bill-photo[data-big="1"] .misc-thumb.active {
  border: 2px solid var(--brand-450);
}

.bill-entry .bill-thumb-btn {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.bill-entry .bill-photo .misc-thumb img,
.bill-entry .bill-photo-strip .misc-thumb.active img {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: cover;
  outline: none;
}

/* 「移除」＝右上角小 ✕ */
.bill-entry .misc-thumb > button.link {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  font-size: 0;
  background: none;
}

.bill-entry .misc-thumb > button.link::before {
  content: "✕";
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin: 5px;
  border-radius: 50%;
  background: rgba(12, 14, 31, 0.6);
  color: #fff;
  font-size: 12px;
  line-height: 1;
}

/* 拍照、上傳照片 → 一格 ⊕（手機選照片時可以選拍照或相簿） */
.bill-entry .bill-photo .misc-photo-btns {
  display: contents;
}

.bill-entry .bill-photo .misc-photo-btns > button:first-child {
  display: none;
}

.bill-entry .bill-photo .misc-photo-btns > button:last-child {
  width: 100px;
  height: 100px;
  min-height: 100px;
  padding: 0;
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-md);
  background: var(--neutral-100);
  font-size: 0;
}

.bill-entry .bill-photo .misc-photo-btns > button:last-child::before {
  content: "";
  display: block;
  width: 24px;
  height: 24px;
  margin: auto;
  background: var(--brand-450);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 8v8M8 12h8'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 8v8M8 12h8'/%3E%3C/svg%3E") center / contain no-repeat;
}

.bill-entry .bill-read-status {
  margin-top: 8px;
  font-size: 14px;
  line-height: 20px;
}

/* 取消／儲存固定在最下面；刪除這張帳單（修改時）排在按鈕上面 */
.bill-entry > .form-error {
  position: sticky;
  bottom: calc(80px + env(safe-area-inset-bottom));
  z-index: 5;
  margin: 16px 0 0;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--error-bg);
  color: var(--error-text);
}

.bill-entry .misc-entry-foot {
  position: sticky;
  bottom: 0;
  z-index: 5;
  flex-wrap: wrap;
  gap: 12px;
  margin: 16px -16px -32px;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  border-top: none;
  background: var(--neutral-0);
  box-shadow: 0 -1px 0 var(--neutral-300);
}

.bill-entry .misc-entry-foot > button.primary,
.bill-entry .misc-entry-foot > a.secondary-link {
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
}

.bill-entry .misc-entry-foot > button.danger {
  flex: 1 0 100%;
  order: -1;
  min-height: 32px;
  justify-content: flex-start;
  text-align: left;
  color: var(--error-text);
}

.bill-entry .misc-entry-foot > a.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border: 1px solid var(--brand-450);
  border-radius: var(--radius-md);
  color: var(--brand-450);
  font-weight: 500;
  text-decoration: none;
}

body:has(.bill-entry) #toasts,
body:has(.bill-m-new) #toasts {
  bottom: calc(96px + env(safe-area-inset-bottom));
}

/* =============================================================
   品項詳情（設計稿 10 清單、11 單一品項）、雜項支出 › 支出類別（24）、匯入 Excel（25）
   docs/design/mobile-prototype-full（PR #108 的完整版）。這幾頁的手機版面是 JS 另外畫的（isPhone()，
   public/js/views/phone-kit.js），class 都是 ph-*；電腦、iPad 照舊。
   設計稿有、系統沒資料的不放：原料／成品分頁、即期、效期、品項編號、－ 出庫。
   ============================================================= */

/* ---- 共用零件：清單列（list-item）、標籤（tag）、卡片（doc-card） ---- */
.ph-list {
  display: flex;
  flex-direction: column;
}

.ph-row {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--neutral-300);
}

.ph-row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 0;
  padding: 16px;
  border: none;
  border-radius: 0;
  background: none;
  color: var(--neutral-800);
  font: inherit;
  font-weight: 400;
  text-align: left;
  text-decoration: none;
}

a.ph-row-main:active,
button.ph-row-main:active {
  background: var(--neutral-100);
}

.ph-row-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ph-row-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
}

.ph-row-desc {
  font-size: 14px;
  line-height: 20px;
  color: var(--neutral-600);
  overflow-wrap: anywhere;
}

.ph-row-value {
  flex: none;
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
  white-space: nowrap;
}

.ph-row-value.ph-muted,
.ph-muted {
  color: var(--neutral-500);
}

.ph-row-warn {
  background: var(--warning-bg);
}

/* 右邊的 ›（設計稿 chevronRight） */
.ph-chev {
  flex: none;
  width: 8px;
  height: 8px;
  margin: 0 20px 0 -4px;
  border-right: 2px solid var(--neutral-800);
  border-top: 2px solid var(--neutral-800);
  transform: rotate(45deg);
  pointer-events: none;
}

.ph-row:has(.ph-chev) .ph-row-main {
  padding-right: 8px;
}

.ph-row:has(.ph-icon-btn) .ph-row-main {
  padding-right: 4px;
}

.ph-tag {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 4px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  line-height: 18px;
  font-weight: 400;
  white-space: nowrap;
}

.ph-tag-warning { background: var(--warning-bg); color: var(--warning-text); }
.ph-tag-error { background: var(--error-bg); color: var(--error-text); }
.ph-tag-success { background: var(--success-bg); color: var(--success-text); }
.ph-tag-neutral { background: var(--neutral-100); color: var(--neutral-700); }
.ph-tag-info { background: var(--brand-50); color: var(--brand-450); }

/* 標題列旁邊的標籤（設計稿 11：品名＋正常） */
#page-title .ph-tag {
  margin-left: 8px;
  vertical-align: 4px;
}

.ph-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-md);
  background: var(--neutral-0);
}

.ph-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ph-card-head h2 {
  margin: 0;
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
}

.ph-card-actions {
  display: flex;
  gap: 4px;
  margin: -12px -8px -12px 0;
}

.ph-card-actions button.link {
  padding: 0 8px;
}

/* 編輯／合併到…：小的外框按鈕（Dennis 2026-11-20） */
.ph-card-actions {
  gap: 8px;
  margin: 0;
}

.ph-card-actions button.ph-sm-btn {
  min-height: 32px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
}

.ph-kv {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
}

.ph-kv > div {
  display: flex;
  gap: 8px;
}

.ph-kv dt {
  flex: none;
  width: 104px;
  color: var(--neutral-600);
}

.ph-kv dd {
  flex: 1;
  margin: 0;
  text-align: right;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.ph-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ph-h2 {
  margin: 0;
  font-size: 20px;
  line-height: 30px;
  font-weight: 700;
}

.ph-caption {
  margin: 0;
  font-size: 12px;
  line-height: 18px;
  color: var(--neutral-600);
}

.ph-empty {
  margin: 0;
  padding: 24px 16px;
  border-radius: var(--radius-md);
  background: var(--neutral-100);
  color: var(--neutral-600);
  text-align: center;
}

.ph-btn-row {
  display: flex;
  gap: 8px;
}

.ph-btn-row > * {
  flex: 1;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* 收合（設計稿 accordion）：AI 新增的品項 */
.ph-acc {
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-md);
  background: var(--neutral-0);
}

.ph-acc > summary {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 44px 12px 16px;
  list-style: none;
  cursor: pointer;
}

.ph-acc > summary::-webkit-details-marker {
  display: none;
}

.ph-acc > summary::after {
  content: "";
  position: absolute;
  right: 20px;
  top: 50%;
  width: 9px;
  height: 9px;
  margin-top: -7px;
  border-right: 2px solid var(--neutral-800);
  border-bottom: 2px solid var(--neutral-800);
  transform: rotate(45deg);
  transition: transform 0.2s;
}

.ph-acc[open] > summary::after {
  margin-top: -2px;
  transform: rotate(-135deg);
}

.ph-acc-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
}

.ph-acc-desc {
  font-size: 14px;
  line-height: 20px;
  color: var(--neutral-600);
}

.ph-acc .ai-review-list {
  padding: 0 16px 8px;
  border-top: 1px solid var(--neutral-300);
}

.ph-acc .ai-review-list li {
  padding: 12px 0;
}

/* ---- 設計稿 10 品項詳情 清單 ---- */
#view.pv-page > * + * {
  margin-top: 16px;
}

/* 搜尋框：左邊放大鏡，按 Enter 就找（「查詢」按鈕手機不放） */
.pv-it-search .pv-it-q {
  max-width: none;
  padding-left: 44px;
  background: var(--neutral-0) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23757680' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-4-4'/%3E%3C/svg%3E") no-repeat 16px center;
  -webkit-appearance: none;
  appearance: none;
}

.pv-it-search > button {
  display: none;
}

.ph-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

button.ph-chip {
  min-height: 32px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--neutral-300);
  border-radius: 999px;
  background: var(--neutral-0);
  color: var(--neutral-800);
  font-size: 14px;
  line-height: 30px;
  font-weight: 400;
}

button.ph-chip.is-on {
  border-color: var(--brand-450);
  background: var(--brand-50);
  color: var(--brand-450);
  font-weight: 500;
}

/* ---- 設計稿 11 單一品項 ---- */
.ph-detail {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ph-big {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px;
  font-size: 32px;
  line-height: 48px;
  font-weight: 700;
}

.ph-big small {
  font-size: 16px;
  line-height: 24px;
  font-weight: 400;
  color: var(--neutral-600);
}

.ph-big.ph-muted {
  font-size: 20px;
  line-height: 30px;
}

.ph-big-more {
  width: 100%;
  font-size: 14px;
  line-height: 20px;
  font-weight: 400;
  color: var(--neutral-600);
}

.ph-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ph-bar {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: var(--neutral-300);
}

.ph-bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--brand-450);
}

.ph-bar-low > span { background: var(--warning-icon); }
.ph-bar-critical > span { background: var(--error-border); }

/* 安全庫存的橘色刻度 */
.ph-bar > i {
  position: absolute;
  top: -2px;
  width: 2px;
  height: 12px;
  background: var(--warning-icon);
}

.ph-detail .ph-list .ph-row-main {
  padding-left: 16px;
}

/* 編輯品項（沿用電腦版的表單）：一格一行，說明文字手機不放 */
.ph-card .pv-it-edit {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ph-card .pv-it-edit .pv-it-hint {
  display: none;
}

.ph-card .pv-it-edit input,
.ph-card .pv-it-edit select {
  width: 100%;
}

.ph-card .pv-it-actions {
  display: flex;
  gap: 8px;
}

.ph-card .pv-it-actions > * {
  flex: 1;
}

/* ---- 雜項支出 › 支出類別（24）、匯入 Excel（25） ---- */
/* 分頁：跟輸入、支出明細一樣是底線式大字 */
#view:has(> .misc-ph) > .pill-tabs {
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 0;
  margin: 0 -16px 8px;
  padding: 0 16px;
  border-bottom: 1px solid var(--neutral-300);
  scrollbar-width: none;
}

#view:has(> .misc-ph) > .pill-tabs::-webkit-scrollbar {
  display: none;
}

#view:has(> .misc-ph) > .pill-tabs .pill {
  position: relative;
  flex: none;
  min-height: 50px;
  padding: 10px 8px;
  border: none;
  border-radius: 0;
  background: none;
  color: var(--neutral-600);
  font-size: 20px;
  line-height: 30px;
  font-weight: 700;
}

#view:has(> .misc-ph) > .pill-tabs .pill.active {
  color: var(--neutral-800);
}

#view:has(> .misc-ph) > .pill-tabs .pill.active::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 0;
  height: 3px;
  border-radius: 2px 2px 0 0;
  background: var(--brand-450);
}

.misc-ph {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 16px;
}

.misc-ph > .ph-section + .ph-section {
  margin-top: 8px;
}

/* 垃圾桶（設計稿 icon-btn brand） */
button.ph-icon-btn {
  flex: none;
  width: 40px;
  min-height: 40px;
  height: 40px;
  margin-right: 8px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--brand-450);
}

/* 新類別名稱｜新增 */
.ph-add-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.ph-add-row input {
  flex: 1;
  min-width: 0;
}

.ph-add-row button {
  flex: none;
  padding: 0 16px;
}

.ph-add-btn {
  margin-top: 8px;
  width: 100%;
}

/* 匯入 Excel：說明一行、虛線框選檔（設計稿 upload-box） */
.ph-lead {
  margin: 0;
  font-size: 16px;
  line-height: 24px;
  color: var(--neutral-700);
}

button.ph-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 24px 16px;
  border: 1px dashed var(--neutral-300);
  border-radius: var(--radius-md);
  background: var(--neutral-100);
  color: var(--neutral-700);
  font-weight: 400;
}

.ph-upload-icon {
  width: 32px;
  height: 32px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 24 24' fill='none' stroke='%231f3d2c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4v10M8 10l4 4 4-4M4 16v3a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-3'/%3E%3C/svg%3E") no-repeat center;
}

.ph-upload-label {
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
  color: var(--neutral-800);
}

.ph-import-result {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ph-sum {
  margin: 0;
  font-size: 16px;
  line-height: 24px;
}

/* 提醒（設計稿 notice） */
.ph-notice {
  padding: 16px;
  border-radius: var(--radius-md);
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
}

.ph-notice ul {
  margin: 8px 0 0;
  padding-left: 20px;
  font-weight: 400;
}

.ph-notice-warning { background: var(--warning-bg); color: var(--warning-text); }
.ph-notice-error { background: var(--error-bg); color: var(--error-text); }
.ph-notice-info { background: var(--brand-50); color: var(--brand-800); }

/* 「匯入 N 筆」固定在最下面（設計稿 bottom-bar） */
#view:has(> .misc-ph .ph-bottom) {
  padding-bottom: calc(112px + env(safe-area-inset-bottom));
}

.ph-bottom {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  background: var(--neutral-0);
  box-shadow: 0 -1px 0 var(--neutral-300);
}

.ph-bottom > button {
  width: 100%;
}

body:has(.ph-bottom) #toasts {
  bottom: calc(96px + env(safe-area-inset-bottom));
}

/* =============================================================
   薪資費用（#/payroll/…）：照手機版設計稿 14 薪資費用、15 異常確認、16 工資清冊、17 匯入打卡（PR #108 mobile-prototype-full）
   - 分頁（班表｜算薪｜薪資設定）：底線式大字（設計稿 tabs-full）；三個分頁都是系統原本就有的，照留
   - 月份：「11 月薪資」＋右邊下拉（設計稿 14），取代 ‹ ›；這個月的發薪狀態標籤跟在標題後面
   - 算薪：第一個畫面＝進度條＋六個步驟（薪水工具真的六張卡片，設計稿畫五步）＋本月數字；點一步＝只看那一張卡片，
     上面「← 薪資費用」回來。卡片裡面的樣子寫在薪水工具（tools/salary/ui.html 的 .in-kitchen.phone）
   - 暫存、儲存／通知人資（主管）固定在畫面最下面（設計稿 bottom-bar）
   ============================================================= */
#view nav.payroll-tabs {
  flex-wrap: wrap;
  gap: 0;
  margin: 0 0 16px;
  padding: 0;
  border-bottom: none;
  /* 分頁下面那條灰線拉滿整排（設計稿 tabs）；月份那一排在線下面 */
  background: linear-gradient(var(--neutral-300), var(--neutral-300)) no-repeat 0 49px / 100% 1px;
}

#view nav.payroll-tabs > .pill {
  position: relative;
  flex: none;
  min-height: 50px;
  padding: 10px 8px;
  border: none;
  border-radius: 0;
  background: none;
  color: var(--neutral-600);
  font-size: 20px;
  line-height: 30px;
  font-weight: 700;
}

#view nav.payroll-tabs > .pill.active {
  color: var(--neutral-800);
}

#view nav.payroll-tabs > .pill.active::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 0;
  height: 3px;
  border-radius: 2px 2px 0 0;
  background: var(--brand-450);
}

#view nav.payroll-tabs > .month-bar {
  display: none;
}

#view nav.payroll-tabs > .payroll-month-phone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  margin-top: 16px;
}

.payroll-month-phone h2 {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  font-size: 20px;
  line-height: 30px;
  font-weight: 700;
}

.payroll-month-phone h2 .run-status {
  font-size: 12px;
  line-height: 18px;
  font-weight: 400;
}

.payroll-month-phone select {
  flex: none;
  width: 160px;
}

/* ---- 算薪 第一個畫面（設計稿 14）---- */
#view > .salary-hub {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#view:not(.salary-phone-sub) > .salary-frame {
  display: none;
}

/* 打開的那一步：箭頭朝下，卡片接在它下面（Dennis 2026-11-19 原地展開） */
.salary-step.is-open {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.salary-step.is-open .step-chev {
  transform: rotate(90deg);
}

.salary-step {
  scroll-margin-top: 72px;
}

#view.salary-phone-sub > .salary-hub {
  margin-bottom: 0;
}

.salary-progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.salary-progress-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--neutral-300);
  overflow: hidden;
}

.salary-progress-bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--brand-450);
}

.salary-progress p {
  margin: 0;
  font-size: 16px;
  line-height: 24px;
}

.salary-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.salary-step {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 0;
  padding: 12px 16px;
  border: 1px solid var(--neutral-300);
  border-radius: 12px;
  background: var(--neutral-0);
  color: var(--neutral-800);
  text-align: left;
  font-weight: 400;
}

.salary-step .step-num {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--neutral-200);
  color: var(--neutral-700);
  font-weight: 500;
}

.salary-step.is-done .step-num {
  background: var(--success-bg);
  color: var(--success-text);
}

.salary-step.is-todo .step-num {
  background: var(--brand-450);
  color: var(--neutral-0);
}

.salary-step .step-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.salary-step .step-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
}

.salary-step .step-desc {
  font-size: 14px;
  line-height: 20px;
  color: var(--neutral-600);
}

.salary-step .step-chev,
.staff-item::after {
  flex: none;
  width: 24px;
  height: 24px;
  background: no-repeat center / 24px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230c0e1f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 6l6 6-6 6'/%3E%3C/svg%3E");
}

/* 設計稿的 tag-status：高 28、圓角 4、12px */
.salary-step .tag,
.staff-item .tag,
.person-head h2 .tag {
  display: inline-flex;
  align-items: center;
  height: 28px;
  margin: 0;
  padding: 0 4px;
  border: none;
  border-radius: var(--radius-xs);
  font-size: 12px;
  line-height: 18px;
  font-weight: 400;
  white-space: nowrap;
}

.tag-success,
.staff-status-phone {
  background: var(--success-bg);
  color: var(--success-text);
}

.tag-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.tag-completed {
  background: var(--neutral-200);
  color: var(--neutral-700);
}

.salary-kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.salary-kpi {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 16px;
  border: 1px solid var(--neutral-300);
  border-radius: 12px;
  background: var(--neutral-0);
}

.salary-kpi .k,
.salary-kpi .d {
  font-size: 12px;
  line-height: 18px;
  color: var(--neutral-600);
}

.salary-kpi .k {
  color: var(--neutral-700);
}

.salary-kpi .v {
  font-size: 20px;
  line-height: 30px;
  font-weight: 700;
}

.salary-hist-phone {
  width: 100%;
}

/* 班表上面「8 行，所有在職員工都算進去了」手機不顯示（Dennis 2026-11-19）；有人沒算到的黃色提醒照樣顯示 */
.payroll-notice-all {
  display: none;
}

/* 打開的那一步下面接著薪水工具的卡片，跟下一步隔開 */
#view.salary-phone-sub > .salary-frame.salary-frame-flow + .salary-hub-after {
  margin-top: 8px;
}

/* 標題字樣（員工資料單一員工也用） */
.person-head h2 {
  margin: 0;
  font-size: 24px;
  line-height: 36px;
  font-weight: 700;
  color: var(--neutral-800);
}

.staff-back {
  min-height: 40px;
  padding: 0;
  border: none;
  background: none;
  color: var(--neutral-600);
  font-size: 16px;
  font-weight: 500;
}

/* 薪水工具跟內容一樣高，沒有框，整頁一起捲 */
#view.salary-phone-sub > .salary-frame.salary-frame-flow {
  display: block;
  min-height: 0;
  border: 0;
  border-radius: 0;
}

/* ---- 置底：暫存、儲存／通知（設計稿 bottom-bar）---- */
#view > .salary-bottom:not([hidden]),
.staff-side > .staff-add,
.person-head .actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
  padding: 16px 16px max(16px, env(safe-area-inset-bottom));
  background: var(--neutral-0);
  box-shadow: 0 -1px 0 var(--neutral-300);
}

#view:has(> .salary-bottom:not([hidden])),
#view:has(.staff-layout) {
  padding-bottom: 120px;
}

.salary-bottom-st {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 20px;
  color: var(--neutral-600);
}

.salary-bottom-st.dirty {
  color: var(--warning-text);
}

.salary-bottom-st.saved {
  color: var(--success-text);
}

.salary-bottom-btns {
  display: flex;
  gap: 12px;
}

.salary-bottom-btns button {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  padding: 0 4px;
  white-space: nowrap;
}

/* 三顆（暫存＋通知人資＋通知主管）時字小一號，才放得下一排 */
.salary-bottom-btns button:first-child:nth-last-child(3),
.salary-bottom-btns button:first-child:nth-last-child(3) ~ button {
  font-size: 14px;
}

/* =============================================================
   員工資料（#/people）：照手機版設計稿 18 員工資料 清單、19 單一員工（PR #108 mobile-prototype-full）
   - 清單：搜尋（放大鏡）、在職／離職分頁、一人一列（名字＋標籤／員工編號・廠區・月薪時薪 ›），「＋新增員工」固定在最下面
   - 上面五張數字卡、說明文字、「顯示離職」勾選在手機不放（設計稿沒有）；缺資料、證照到期照樣標在每一列
   - 點一個人＝另一個畫面：「← 員工資料」、名字＋在職標籤、分頁底線式大字、欄位一個一排、標題在上
   - 下面固定「勞動契約」「修改資料」（改的時候是「取消」「儲存…」），簽好的契約狀態寫在按鈕上面
   ============================================================= */
#view > .staff-head {
  display: none;
}

.staff-layout {
  display: block;
}

.staff-side.card,
.staff-pane.card {
  padding: 0;
  border: none;
  border-radius: 0;
  background: none;
  box-shadow: none;
}

.staff-side {
  gap: 16px;
}

.staff-layout.has-person > .staff-side,
.staff-layout:not(.has-person) > .staff-pane {
  display: none;
}

.shell:has(.staff-layout.has-person) .topbar {
  display: none;
}

.staff-side > input[type="search"] {
  padding-left: 44px;
  background: var(--neutral-0) no-repeat 16px center / 20px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23757680' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E");
}

.staff-side > .check-line,
.staff-side > .chips {
  display: none;
}

.staff-side > .staff-tabs-phone {
  display: flex;
  border-bottom: 1px solid var(--neutral-300);
}

.staff-tab {
  position: relative;
  flex: none;
  min-height: 0;
  padding: 6px 12px 10px;
  border: none;
  border-radius: 0;
  background: none;
  color: var(--neutral-600);
  font-size: 16px;
  line-height: 24px;
  font-weight: 400;
}

.staff-tab.active {
  color: var(--neutral-800);
  font-weight: 500;
}

.staff-tab.active::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -1px;
  height: 4px;
  border-radius: 2px 2px 0 0;
  background: var(--brand-450);
}

.staff-items {
  gap: 0;
  max-height: none;
  overflow: visible;
  margin-top: -16px;
}

.staff-item {
  display: grid;
  grid-template-columns: 1fr 24px;
  align-items: center;
  gap: 4px 8px;
  min-height: 0;
  padding: 16px;
  border: none;
  border-bottom: 1px solid var(--neutral-300);
  border-radius: 0;
  background: none;
  color: var(--neutral-800);
}

.staff-item::after {
  content: "";
  grid-column: 2;
  grid-row: 1 / span 3;
}

.staff-item .staff-name {
  flex-wrap: wrap;
  gap: 4px;
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
}

.staff-item > .muted {
  font-size: 14px;
  line-height: 20px;
  color: var(--neutral-600);
}

.staff-item .tag-alert {
  position: static;
  justify-self: start;
}

/* 標籤顏色照設計稿：過期、法規提醒＝紅；快到期＝橘；離職、缺幾項＝灰 */
.staff-item .tag {
  background: var(--neutral-200);
  color: var(--neutral-700);
}

.staff-item .tag-alert-soft,
.staff-item .tag-alert {
  background: var(--error-bg);
  color: var(--error-text);
}

.staff-item .tag-warn:not(.staff-left) {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.staff-item.active {
  background: var(--neutral-100);
}

/* ---- 「＋新增員工」固定在最下面 ---- */
.staff-add > .primary.wide {
  min-height: 48px;
}

/* ---- 單一員工（設計稿 19）---- */
.staff-pane {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.staff-back {
  display: block;
  align-self: flex-start;
  margin-top: 8px;
}

.person-head {
  flex-direction: column;
  align-items: stretch;
}

.person-head h2 {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.person-head h2 > .muted {
  font-size: 16px;
  font-weight: 400;
}

.person-head h2 .staff-status-phone {
  display: inline-flex;
}

.person-head > div:first-child {
  flex: none;
}

.person-head .person-line {
  margin: 4px 0 0;
}

.person-head .actions {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 12px;
}

.person-head .actions > button:not(.link):not(.law-dot) {
  flex: 1;
  min-height: 48px;
}

.person-head .actions > .contract-status,
.person-head .actions > .law-dot {
  flex-basis: 100%;
  justify-content: flex-start;
  min-height: 0;
  margin: -4px 0 0;
  padding: 0;
  font-size: 14px;
  text-align: left;
}

.person-head .actions > .law-dot {
  flex-basis: auto;
}

/* 分頁：底線式大字（設計稿 tabs-full），放不下左右滑 */
.staff-pane > .pill-tabs {
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 0;
  margin: 0 -16px;
  padding: 0 16px;
  border-bottom: 1px solid var(--neutral-300);
  scrollbar-width: none;
}

.staff-pane > .pill-tabs::-webkit-scrollbar {
  display: none;
}

.staff-pane > .pill-tabs .pill {
  position: relative;
  flex: none;
  min-height: 50px;
  padding: 10px 8px;
  border: none;
  border-radius: 0;
  background: none;
  color: var(--neutral-600);
  font-size: 20px;
  line-height: 30px;
  font-weight: 700;
}

.staff-pane > .pill-tabs .pill.active {
  color: var(--neutral-800);
}

.staff-pane > .pill-tabs .pill.active::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 0;
  height: 3px;
  border-radius: 2px 2px 0 0;
  background: var(--brand-450);
}

/* 欄位：一個一排，名字在上（設計稿 field），不用卡片框 */
.staff-pane .field-groups {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.staff-pane .field-group {
  padding: 0;
  border: none;
  border-radius: 0;
  background: none;
  box-shadow: none;
}

.staff-pane .group-head h3 {
  font-size: 16px;
  line-height: 24px;
  color: var(--neutral-600);
}

.staff-pane .field-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.staff-pane .field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.staff-pane .field-label {
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
  color: var(--neutral-800);
}

.staff-pane .field-value {
  min-height: 0;
  padding: 0;
  font-size: 16px;
  line-height: 24px;
}

/* 手機不放說明文字（Dennis 2026-11-12）；欄位、提醒、錯誤照留 */
.staff-pane .field small.muted,
.staff-pane .group-head small {
  display: none;
}

/* =============================================================
   總覽（#/preview/overview）：原本的版面（Dennis 2026-11-19：「原本這樣比較好」）
   損益表／庫存總覽換成一排字＋底線的分頁（跟薪資費用 班表｜算薪｜薪資設定、營業收入一樣）；
   損益表卡片裡多一個提醒（今天未輸入、N 張待確認、本月 N 筆），點了到要輸入的那一頁
   ============================================================= */
.pv-ov-tabs {
  align-items: flex-end;
  border-bottom: 1px solid var(--neutral-300);
}

.pv-ov-tabs > .cat-tabs {
  flex-wrap: nowrap;
  gap: 0;
  margin: 0;
}

.pv-ov-tabs > .cat-tabs button {
  position: relative;
  flex: none;
  min-height: 0;
  margin: 0;
  padding: 10px 8px;
  border: none;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: var(--neutral-500);
  font-size: 20px;
  line-height: 30px;
  font-weight: 700;
}

.pv-ov-tabs > .cat-tabs button::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: -1px;
  height: 4px;
  border-radius: 2px 2px 0 0;
  background: transparent;
}

.pv-ov-tabs > .cat-tabs button[aria-pressed="true"] {
  color: var(--neutral-800);
  background: none;
}

.pv-ov-tabs > .cat-tabs button[aria-pressed="true"]::after {
  background: var(--brand-450);
}

.pv-ov-tabs > .pv-ov-small {
  padding-bottom: 12px;
}

.pv-ov-alert-row {
  margin-top: 8px;
}

a.pv-ov-alert {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 6px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  line-height: 18px;
  text-decoration: none;
  white-space: nowrap;
}

a.pv-ov-alert-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
}

a.pv-ov-alert-neutral {
  background: var(--neutral-100);
  color: var(--neutral-700);
}

/* =============================================================
   帳號：登入（設計稿 L）、改密碼（22）、帳號管理（20）、人員設定（21）
   畫面在 login.js、password.js、admin.js 的手機分支（isPhone），電腦、iPad 不變
   ============================================================= */

/* ---- 共用：欄位（標籤 16 粗、下面輸入框）、標籤 tag、置底按鈕列 ---- */
.m-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.m-field > label {
  margin: 0;
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
  color: var(--neutral-800);
}

.m-help {
  font-size: 12px;
  line-height: 18px;
  color: var(--neutral-700);
}

.m-tag {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 4px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  line-height: 18px;
  font-weight: 400;
  white-space: nowrap;
}

.m-tag.tag-info {
  background: var(--brand-50);
  color: var(--brand-450);
}

.m-tag.tag-success {
  background: var(--success-bg);
  color: var(--success-text);
}

.m-tag.tag-completed {
  background: var(--neutral-100);
  color: var(--neutral-700);
}

.m-tag.tag-error {
  background: var(--error-bg);
  color: var(--error-text);
}

#page-title .m-tag {
  vertical-align: middle;
}

button.tertiary {
  border-color: var(--neutral-300);
  background: var(--neutral-0);
  color: var(--neutral-800);
}

/* 取消／儲存、＋ 新增：一條白底固定在畫面最下面（設計稿 bottom-bar） */
.m-form-foot {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  gap: 12px;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  background: var(--neutral-0);
  box-shadow: 0 -1px 0 var(--neutral-300);
}

.m-form-foot > button,
.m-form-foot > a.button {
  flex: 1;
  margin: 0;
}

.m-form-foot > a.button,
.m-two-btns > a.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--brand-450);
  background: var(--neutral-0);
  text-decoration: none;
}

.m-password,
.m-admin,
.m-staff {
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
}

body:has(.m-form-foot) #toasts {
  bottom: calc(96px + env(safe-area-inset-bottom));
}

/* ---- L 登入：上面一條「央廚系統」，表單離上面 64 ---- */
.m-login {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--neutral-0);
}

.m-login-head {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--header-height);
  border-bottom: 1px solid var(--neutral-300);
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: var(--neutral-800);
}

.m-login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 360px;
  margin: 0 auto;
  padding: 64px 24px 24px;
}

.m-login-form h1 {
  margin: 0;
  font-size: 24px;
  line-height: 36px;
  font-weight: 700;
  color: var(--neutral-800);
}

.m-login-form button.primary {
  margin: 0;
}

.m-login-note {
  margin: 0;
  text-align: center;
  font-size: 12px;
  line-height: 18px;
  color: var(--neutral-700);
}

/* 帳號或密碼不對：紅底通知，在欄位上面（設計稿 notice-error） */
.m-notice-error {
  margin: 0;
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--error-bg);
  color: var(--error-text);
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
}

/* ---- 22 改密碼：三個欄位一欄一欄往下 ---- */
.m-password,
.m-staff {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.m-password .banner,
.m-password .form-error,
.m-staff .form-error {
  margin: 0;
}

/* ---- 20 帳號管理：人員／供應商兩個大頁籤（設計稿 tab-full-page） ---- */
.m-tabs {
  display: flex;
  border-bottom: 1px solid var(--neutral-300);
}

.m-tabs .m-tab {
  position: relative;
  min-height: 0;
  padding: 10px 8px;
  border: none;
  border-radius: 0;
  background: none;
  font-size: 20px;
  line-height: 30px;
  font-weight: 700;
  color: var(--neutral-600);
}

.m-tabs .m-tab.is-active {
  color: var(--neutral-800);
}

.m-tabs .m-tab.is-active::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: -1px;
  height: 4px;
  border-radius: 2px 2px 0 0;
  background: var(--brand-450);
}

/* 一個人／一家供應商一列：名字＋標籤，下面一行小字，右邊 ›（設計稿 list-item） */
.m-list {
  display: flex;
  flex-direction: column;
  margin-top: 16px;
}

.m-list > .muted,
.m-list > .form-error {
  padding: 16px;
}

.m-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 0;
  padding: 16px;
  border: none;
  border-bottom: 1px solid var(--neutral-300);
  border-radius: 0;
  background: none;
  color: var(--neutral-800);
  font-weight: 400;
  text-align: left;
  text-decoration: none;
}

a.m-row:hover,
button.m-row:hover {
  background: var(--neutral-100);
}

.m-row-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.m-row-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
}

.m-row-desc {
  font-size: 14px;
  line-height: 20px;
  color: var(--neutral-600);
}

.m-chevron {
  flex: none;
  width: 24px;
  height: 24px;
  position: relative;
}

.m-chevron::before {
  content: "";
  position: absolute;
  top: 7px;
  left: 6px;
  width: 8px;
  height: 8px;
  border-top: 2px solid var(--neutral-800);
  border-right: 2px solid var(--neutral-800);
  transform: rotate(45deg);
}

/* 修改供應商視窗：要不要盤點、停用（電腦版在表格那一列上） */
.m-dialog-btns,
.m-two-btns {
  display: flex;
  gap: 8px;
}

.m-dialog-btns {
  margin-top: 16px;
}

.m-dialog-btns > *,
.m-two-btns > * {
  flex: 1;
  min-height: 40px;
  padding: 0 12px;
}

/* 手機不放說明文字（PJ 2026-11-10、Dennis 2026-11-12）：新增／修改供應商、重設密碼視窗裡欄位下面的小字 */
dialog.admin-form label > small.muted {
  display: none;
}

/* ---- 21 人員設定：可以看的分頁＝一列一個勾選框 ---- */
.m-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.m-section h2 {
  margin: 0;
  font-size: 20px;
  line-height: 30px;
  font-weight: 700;
  color: var(--neutral-800);
}

.m-section > .muted {
  margin: 0;
}

.m-checks {
  display: flex;
  flex-direction: column;
}

.m-check {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 0;
  padding: 12px 0;
  border: none;
  border-bottom: 1px solid var(--neutral-300);
  border-radius: 0;
  background: none;
  color: var(--neutral-800);
  font-weight: 400;
  text-align: left;
}

.m-check.is-sub {
  padding-left: 32px;
}

.m-check-box {
  flex: none;
  position: relative;
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--neutral-300);
  border-radius: var(--radius-xs);
}

.m-check.is-on .m-check-box {
  background: var(--brand-450);
  border-color: var(--brand-450);
}

.m-check.is-on .m-check-box::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border-right: 2px solid var(--neutral-0);
  border-bottom: 2px solid var(--neutral-0);
  transform: rotate(45deg);
}

/* ---- 權限範本（v0.44）：套用範本時下面的分頁照範本、不能點；範本下拉縮排在「套用範本」下面 ---- */
.m-check.is-locked,
.m-check.is-locked:disabled {
  background: none;
  color: var(--neutral-600);
  cursor: default;
}

.m-check.is-locked .m-check-box {
  background: var(--neutral-400);
  border-color: var(--neutral-400);
}

.m-check-sub {
  padding: 8px 0 8px 32px;
  border-bottom: 1px solid var(--neutral-300);
}

.m-preset .banner {
  margin: 0;
}

/* 「開放以下權限：」那一列，最右邊放「全選」「全取消」（Dennis 2026-11-20） */
.m-check-line {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--neutral-300);
}
.m-check-line > .m-check {
  flex: 1;
  min-width: 0;
  border-bottom: none;
}
.m-check-line-plain {
  min-height: 48px;
  padding: 6px 0;
  justify-content: space-between;
}
.m-check-line button.pages-all-btn {
  min-height: 36px;
  padding: 4px 12px;
  font-size: 0.95rem;
}

/* ---- 品項清單：一列＝下拉，點開看品項詳情（Dennis 2026-11-20） ---- */
.ph-drop {
  border-bottom: 1px solid var(--neutral-300);
}

.ph-drop > summary {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 44px 16px 16px;
  list-style: none;
  cursor: pointer;
}

.ph-drop > summary::-webkit-details-marker {
  display: none;
}

.ph-drop > summary::after {
  content: "";
  position: absolute;
  right: 20px;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -6px;
  border-right: 2px solid var(--neutral-800);
  border-bottom: 2px solid var(--neutral-800);
  transform: rotate(45deg);
  transition: transform 0.2s;
}

.ph-drop[open] > summary::after {
  margin-top: -1px;
  transform: rotate(-135deg);
}

.ph-drop[open] > summary {
  background: var(--neutral-100);
}

.ph-drop-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 16px 16px;
  background: var(--neutral-100);
}

.ph-drop-btns {
  display: flex;
  gap: 8px;
}

.ph-drop-btns > a.button {
  flex: 1;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: var(--neutral-0);
}

/* ---- 單一品項：目前庫存一列（Dennis 2026-11-20） ---- */
.ph-stock-row {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 12px 16px;
}

.ph-stock-left {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.ph-stock-left .ph-caption {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ph-big.ph-big-sm {
  font-size: 24px;
  line-height: 32px;
}

.ph-big.ph-big-sm.ph-muted {
  font-size: 16px;
  line-height: 32px;
}

.ph-stock-btns {
  flex: none;
  display: flex;
  gap: 8px;
}

.ph-stock-btns > a.button {
  min-height: 40px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  font-size: 14px;
}

.ph-stock-bar {
  width: 100%;
}

/* ---- 單一品項 › 基本資料：三欄、欄名在值上面（Dennis 2026-11-20 選 B：左右隔太遠容易對錯行） ---- */
.ph-kv.ph-kv-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 8px;
}

.ph-kv.ph-kv-grid > div {
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ph-kv.ph-kv-grid dt {
  width: auto;
  font-size: 12px;
  line-height: 16px;
}

.ph-kv.ph-kv-grid dd {
  text-align: left;
  font-size: 15px;
  line-height: 20px;
}

/* =============================================================
   盤點（#/count、#/counts）：設計稿畫面 04 的卡片版面。DOM 在 public/js/views/stocktake.js 手機分支（class 開頭 st-m-）。
   ============================================================= */
.st-m-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.st-m-caption {
  font-size: 12px;
  line-height: 18px;
  color: var(--neutral-700);
}

.st-m-progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 16px;
  line-height: 24px;
}

.st-m-progress-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--neutral-300);
  overflow: hidden;
}

.st-m-progress-bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--brand-450);
  transition: width 0.3s;
}

/* 頁籤：未盤／已盤／全部，底線標目前這個 */
.st-m-tabs {
  display: flex;
  border-bottom: 1px solid var(--neutral-300);
  margin-bottom: 16px;
}

.st-m-tab {
  position: relative;
  min-height: 44px;
  padding: 6px 12px 10px;
  border: none;
  border-radius: 0;
  background: none;
  font-size: 16px;
  line-height: 24px;
  font-weight: 400;
  color: var(--neutral-600);
}

.st-m-tab[aria-pressed="true"] {
  color: var(--neutral-800);
  font-weight: 500;
}

.st-m-tab[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -1px;
  height: 4px;
  border-radius: 2px 2px 0 0;
  background: var(--brand-450);
}

.st-m-small {
  min-height: 40px;
  padding: 0 12px;
  font-size: 16px;
}

/* 盤點單：品項依儲區分組，每項一張卡 */
.st-m > p.muted:first-child {
  margin: 0;
  font-size: 12px;
  line-height: 18px;
  color: var(--neutral-700);
}

.st-m > * + * {
  margin-top: 16px;
}

.st-m .pv-bar {
  display: block;
  margin-bottom: 16px;
}

.st-m .pv-bar > .st-m-row {
  justify-content: flex-end;
}

.st-m .pv-bar > .st-m-row:has(.st-m-caption:not(:empty)) {
  justify-content: space-between;
}

.st-m .pv-tabs,
.st-m .pv-cards {
  display: none;
}

/* 六區卡：三個一排，在進度條下面 */
.st-m .st-zones {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.st-m .st-zone {
  min-height: 0;
  padding: 10px 12px;
  border-color: var(--neutral-300);
  border-radius: var(--radius-md);
}

.st-m .st-zone[aria-pressed="true"] {
  border-color: var(--brand-450);
  box-shadow: 0 0 0 1px var(--brand-450);
  background: var(--brand-50);
}

.st-m .st-zone-label {
  font-size: 14px;
  line-height: 20px;
  color: var(--neutral-700);
}

.st-m .st-zone-value {
  font-size: 24px;
  line-height: 32px;
  color: var(--brand-450);
}

.st-m .st-zone-sub {
  font-size: 12px;
  line-height: 18px;
  color: var(--neutral-600);
}

.st-m-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.st-m-group + .st-m-group {
  margin-top: 16px;
}

.st-m-group-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.st-m-group-head h2 {
  margin: 0;
  font-size: 16px;
  line-height: 24px;
  font-weight: 500;
}

.st-m-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-md);
  background: var(--neutral-0);
}

.st-m-name {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  min-width: 0;
  font-size: 16px;
  line-height: 24px;
}

.st-m-name b {
  font-weight: 500;
}

.st-m-card .st-m-row .st-m-row {
  flex: none;
  gap: 4px;
}

.st-m-card .st-m-row button.link {
  min-height: 32px;
  padding: 0 4px;
  color: var(--error-text);
}

/* 搜尋品名：整排、左邊放大鏡（Dennis 2026-11-20） */
.st-m .st-search {
  max-width: none;
  margin: 0 0 16px;
  padding-left: 44px;
  background: var(--neutral-0) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23757680' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-4-4'/%3E%3C/svg%3E") no-repeat 16px center;
  -webkit-appearance: none;
  appearance: none;
}

/* 儲區下拉：箭頭往內縮 16px，跟輸入框的字一樣有留白（Dennis 2026-11-20） */
.st-m-card select {
  width: 100%;
  padding: 0 48px 0 16px;
  background: var(--neutral-0) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='8'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%235e5f6b' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 18px center;
  -webkit-appearance: none;
  appearance: none;
}

.st-m-card select:disabled {
  background-color: var(--neutral-200);
}

/* 應有數量：一行，左邊「應有 12 包」，右邊小字怎麼來的 */
.st-m-expected {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 8px;
  font-size: 16px;
  line-height: 24px;
}

.st-m-expected b {
  font-weight: 500;
}

/* 數量：－ ［數量 單位］ ＋，同一個框 */
.st-m-num {
  display: flex;
  align-items: stretch;
  height: 48px;
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--neutral-0);
}

.st-m-num:focus-within {
  border-color: var(--brand-450);
  box-shadow: 0 0 0 1px var(--brand-450);
}

.st-m-num:has(input[aria-invalid="true"]) {
  border-color: var(--error-border);
  box-shadow: 0 0 0 1px var(--error-border);
}

/* − ＋：淡綠底的方塊，符號大一點，一看就是按鈕（Dennis 2026-11-20） */
.st-m-step {
  flex: none;
  width: 56px;
  min-height: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: var(--brand-100);
  font-size: 30px;
  font-weight: 500;
  line-height: 1;
  color: var(--brand-450);
}

.st-m-step:first-child {
  border-right: 1px solid var(--neutral-300);
}

.st-m-step:last-child {
  border-left: 1px solid var(--neutral-300);
}

.st-m-step:active {
  background: var(--brand-200);
}

.st-m-step:disabled {
  background: var(--neutral-100);
  color: var(--neutral-400);
}

.st-m-num-field {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.st-m-num-field input.st-m-qty {
  flex: 0 1 auto;
  width: 100%;
  min-width: 0;
  min-height: 0;
  height: 100%;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  text-align: center;
  box-shadow: none;
}

.st-m-num-field input.st-m-qty:disabled {
  background: transparent;
  color: var(--neutral-600);
}

.st-m-unit {
  flex: none;
  padding-right: 8px;
  color: var(--neutral-700);
}

.st-m-num-field:has(input:placeholder-shown) .st-m-unit {
  color: var(--neutral-500);
}

.st-m-empty {
  margin: 0;
  padding: 24px 16px;
  border-radius: var(--radius-md);
  background: var(--neutral-100);
  text-align: center;
  font-size: 14px;
  line-height: 20px;
  color: var(--neutral-700);
}

/* 手動加入品項：欄位一個一行 */
.st-m .pv-ct-add-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.st-m .pv-ct-add-row input,
.st-m .pv-ct-add-row select {
  width: 100%;
}

.st-m-cancel {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

.st-m-cancel button.link {
  color: var(--error-text);
}

/* 暫存＋完成盤點固定在畫面最下面（外面那層 div 不算高度，sticky 才會跟著整頁） */
.st-m > div:has(> .st-m-bottom) {
  display: contents;
}

.st-m-bottom {
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: flex;
  gap: 12px;
  margin: 16px -16px -32px;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  background: var(--neutral-0);
  box-shadow: 0 -1px 0 var(--neutral-300);
}

.st-m-bottom button {
  flex: 1;
}

/* 盤點紀錄：每張單一張卡 */
.st-m-hist {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.st-m-hist-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-md);
  color: var(--neutral-800);
  text-decoration: none;
}

.st-m-hist-card b {
  font-weight: 500;
}


/* 品項紀錄（#/stock/:id）：先是小卡一行「日期 供應商 數量」，點了打開大卡（Dennis 2026-11-24） */
.history table.list tr.st-rec {
  cursor: pointer;
}

.history table.list tr.st-rec td.c-compact {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  font-size: 16px;
  line-height: 24px;
  text-align: left;
}

.history table.list tr.st-rec td.c-compact > span:last-child {
  text-align: right;
}

.history table.list tr.st-rec:not(.open) td:not(.c-compact),
.history table.list tr.st-rec.open td.c-compact {
  display: none;
}

/* 大卡：跟單一品項的基本資料一樣，三欄、欄名小灰字在上、值粗字在下（Dennis 2026-11-24：左右拉太開會對錯行） */
.history table.list tr.st-rec.open {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 8px;
}

.history table.list tr.st-rec.open td:not(.c-compact) {
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 2px;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 20px;
  text-align: left;
  overflow-wrap: anywhere;
}

.history table.list tr.st-rec.open td[data-label]::before {
  font-size: 12px;
  font-weight: 400;
  line-height: 16px;
}

/* 大卡標題＝品名（像基本資料卡的標題），下面 3 欄 × 2 列：日期、供應商、進貨單／數量、單價、總價（Dennis 2026-11-26） */
.history table.list tr.st-rec.open td.c-item {
  order: -1;
  grid-column: 1 / -1;
  display: block;
  margin-bottom: 4px;
  font-size: 18px;
  line-height: 26px;
  font-weight: 600;
}

.history table.list tr.st-rec.open td.c-item::before {
  content: none;
}

.history table.list tr.st-rec.open td.c-item .muted {
  font-size: 14px;
  font-weight: 400;
}
