/* 央廚系統：深綠側邊欄、米色底、赤陶色主要按鈕。目標：iPad Safari（直／橫）與筆電瀏覽器。 */
:root {
  --green: #1f3d2c;
  --green-2: #2c5440;
  --green-soft: #e5ebe3;
  --cream: #fbf6ec;
  --card: #ffffff;
  --line: #e6dfd2;
  --text: #1f2a24;
  --muted: #6b7068;
  --terracotta: #c4552f;
  --terracotta-dark: #a8462a;
  --gold: #d9a441;
  --gold-line: #d4ae45;
  --alert: #c0583a;
  --danger: #b3261e;
  --warn-bg: #fdf3d8;
  --radius: 10px;
  --sidebar: 220px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--cream);
  -webkit-text-size-adjust: 100%;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--cream);
}

[hidden] {
  display: none !important;
}

a {
  color: var(--green-2);
}

h1 {
  font-size: 1.4rem;
  margin: 0;
}

/* ---- 表單與按鈕 ---- */
input,
select,
textarea,
button {
  font: inherit;
  color: inherit;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--green-2);
  outline-offset: 0;
  border-color: transparent;
}

label {
  display: block;
  margin: 14px 0 6px;
  font-size: 0.9rem;
  color: var(--muted);
}

button {
  min-height: 44px;
  padding: 8px 18px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
}

button:disabled {
  opacity: 0.6;
  cursor: default;
}

button.primary {
  background: var(--terracotta);
  border-color: var(--terracotta);
  color: #fff;
  font-weight: 600;
}

button.primary:hover:not(:disabled) {
  background: var(--terracotta-dark);
}

button.secondary {
  background: #fff;
}

button.link {
  border: none;
  background: none;
  padding: 0 4px;
  min-height: 44px;
  color: var(--green-2);
  text-decoration: underline;
}

button.wide {
  width: 100%;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.form-error {
  color: var(--danger);
  margin: 12px 0 0;
}

.muted {
  color: var(--muted);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

.card > label:first-child {
  margin-top: 0;
}

.card.narrow {
  max-width: 440px;
}

/* ---- 登入 ---- */
.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 28px;
}

.login-brand {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--green);
  margin-bottom: 8px;
}

.login-card button.primary {
  margin-top: 22px;
}

/* ---- 外框 ---- */
/* 側邊欄規格：寬 220、上下 20 左右 14、選中 = 白 16% + 金色左線 3px + 粗體，提醒放右邊 */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--green);
  color: #fff;
  padding: 20px 14px;
  padding-left: max(14px, env(safe-area-inset-left));
}

.brand {
  font-weight: 700;
  font-size: 18px;
  padding: 4px 12px 10px;
}

.sidebar nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-group-title {
  padding: 14px 12px 6px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.5);
}

.sidebar nav a[data-nav] {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
  padding: 9px 12px;
  border-radius: 8px;
  border-left: 3px solid transparent;
  color: #fff;
  font-size: 15px;
  text-decoration: none;
  white-space: nowrap;
}

.sidebar nav a[data-nav]:hover {
  background: rgba(255, 255, 255, 0.08);
}

.sidebar nav a[data-nav][aria-current="page"] {
  background: rgba(255, 255, 255, 0.16);
  border-left-color: var(--gold-line);
  font-weight: 700;
}

/* 進貨入庫右邊的紅色數字：自己是一個連結（打開待確認），點的範圍比看起來大 */
.nav-item {
  position: relative;
}

.sidebar a.badge {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  text-decoration: none;
}

.nav-item:has(.badge:not([hidden])) a[data-nav] {
  padding-right: 48px;
}

.section-hint {
  margin: -6px 0 12px;
  font-size: 0.9rem;
}

.sidebar a.badge::before {
  content: "";
  position: absolute;
  inset: -11px -10px;
}

.sidebar a.badge:hover {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35);
}

.badge {
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 11px;
  background: var(--alert);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 22px;
  text-align: center;
}

/* 使用者：放最下面，上方一條分隔線 */
.sidebar .user {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 4px 10px;
  margin-top: 12px;
  padding: 14px 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--gold-line);
  color: var(--green);
  font-weight: 700;
}

.user-name {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-role {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
}

.user-links {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  font-size: 13px;
}

.user-links a,
.user-links button.link {
  min-height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
}

.user-links a:hover,
.user-links button.link:hover {
  color: #fff;
  text-decoration: underline;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  padding: 20px 28px 4px;
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
  font-size: 12.5px;
  color: var(--muted);
}

.crumbs a {
  color: var(--muted);
  text-decoration: none;
}

.crumbs a:hover {
  color: var(--green);
  text-decoration: underline;
}

.crumbs a:last-of-type {
  color: var(--green);
  font-weight: 600;
}

.title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
}

.title-row h1 {
  font-size: 1.6rem;
  color: var(--green);
}

#page-actions {
  display: flex;
  gap: 14px;
}

#page-actions a {
  color: var(--green);
  font-weight: 600;
  text-decoration: none;
}

#page-actions a:hover {
  text-decoration: underline;
}

#page-actions:empty {
  display: none;
}

.back-link {
  font-size: 0.95rem;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}

.back-link:hover {
  color: var(--green);
}

.topbar-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 18px;
  margin-left: auto;
  font-size: 0.9rem;
  color: var(--muted);
  white-space: nowrap;
}

#view {
  padding: 16px 28px 40px;
}

/* 窄於 900px（iPad 直放）：側邊欄變成上方列 */
@media (max-width: 899px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 6px 12px;
    overflow-x: auto;
  }

  .brand {
    padding: 0 8px;
    white-space: nowrap;
  }

  .sidebar nav,
  .nav-group {
    flex-direction: row;
  }

  .nav-group-title {
    display: none;
  }

  .sidebar nav a[data-nav] {
    border-left: none;
    border-bottom: 3px solid transparent;
    border-radius: 6px;
  }

  .sidebar nav a[data-nav][aria-current="page"] {
    border-bottom-color: var(--gold-line);
  }

  .sidebar .user {
    display: flex;
    margin: 0;
    padding: 0;
    border: none;
  }

  .sidebar .user .avatar,
  .user-text {
    display: none;
  }

  .user-links {
    flex-wrap: nowrap;
    white-space: nowrap;
  }

  .topbar {
    padding: 14px 16px 0;
  }

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

/* 手機：不特別處理，只要不壞掉 */
@media (max-width: 520px) {
  .brand {
    display: none;
  }
}

/* 看起來像按鈕的連結 */
a.button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 18px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--green);
  font-weight: 600;
  text-decoration: none;
}

a.button:hover {
  border-color: var(--green-2);
}

.page-links {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ---- 提示與對話框 ---- */
#toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
}

.toast {
  max-width: 360px;
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.toast-error {
  background: var(--danger);
}

dialog.confirm {
  max-width: 420px;
  width: calc(100% - 32px);
  border: none;
  border-radius: var(--radius);
  padding: 24px;
}

dialog.confirm::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

/* 班表：點格子跳出的小視窗（輸入當天上下班時間，或改成休假） */
dialog.cell-editor {
  max-width: 660px;
  width: calc(100% - 32px);
  border: none;
  border-radius: var(--radius);
  padding: 20px 24px;
}

dialog.cell-editor::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

dialog.cell-editor h3 {
  margin: 0 0 14px;
  font-size: 1.05rem;
}

.cell-times,
.cell-day,
.form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.cell-day {
  margin-bottom: 10px;
}

.cell-day button {
  min-width: 56px;
}

.cell-day button.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.cell-times label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.cell-times input[type="time"],
.form-row input[type="time"] {
  width: 7.5rem;
}

.form-row input[type="time"] {
  width: 8rem;
}

.cell-times input:disabled {
  opacity: 0.4;
}

.day-hrs {
  white-space: nowrap;
}

/* 小視窗裡的請假／加班：一行一張單 */
.cell-section {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.cell-section h4 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.form-row {
  margin-bottom: 8px;
}

.form-row select {
  width: 9rem;
}

.form-row .remove {
  font-size: 1.1rem;
  text-decoration: none;
  color: var(--muted);
}

.cell-section .add-row {
  font-weight: 600;
  text-decoration: none;
}

dialog.cell-editor .actions {
  margin-top: 12px;
}

dialog.confirm p {
  margin: 0;
  white-space: pre-line;
}

/* ---- 共用：區塊標題、切換鈕、表格、標籤 ---- */
h2 {
  font-size: 1.1rem;
  margin: 0;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.seg button {
  border: none;
  border-radius: 0;
  min-height: 40px;
  padding: 6px 16px;
  background: #fff;
}

.seg button + button {
  border-left: 1px solid var(--line);
}

.seg button[aria-pressed="true"] {
  background: var(--green-2);
  color: #fff;
  font-weight: 600;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.list {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

table.list th,
table.list td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

table.list th {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--muted);
}

table.list td.num,
table.list th.num {
  text-align: right;
}

table.list tr.clickable {
  cursor: pointer;
}

table.list tr.clickable:hover td {
  background: var(--green-soft);
}

.tag {
  display: inline-block;
  margin-left: 6px;
  padding: 0 8px;
  border-radius: 10px;
  font-size: 0.8rem;
  line-height: 20px;
  background: var(--green-soft);
}

.tag-draft {
  background: #e1ebee;
  color: #3d6b78;
  font-weight: 600;
}

.tag-warn {
  background: var(--warn-bg);
  color: #8a5a00;
}

table.list td.num .tag {
  margin-left: 0;
}

button.danger {
  color: var(--danger);
}

a.button-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 18px;
  border-radius: 8px;
  border: 1px solid var(--green-2);
  color: var(--green-2);
  font-weight: 600;
  text-decoration: none;
}

/* ---- 進貨入庫 ---- */
.receive {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.drop-zone {
  border: 2px dashed var(--line);
  text-align: center;
}

.drop-zone.dragover {
  border-color: var(--terracotta);
  background: #fdf1ea;
}

button.big {
  min-height: 64px;
  padding: 12px 36px;
  font-size: 1.15rem;
  border-radius: 12px;
}

.drop-hint {
  margin: 10px 0 0;
  font-size: 0.9rem;
}

.drop-zone h2 {
  margin-top: 20px;
  text-align: left;
}

.queue,
.failed-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  text-align: left;
}

.queue-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.queue-row:last-child {
  border-bottom: none;
}

.thumb {
  display: block;
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--green-soft);
}

.queue-status {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.queue-detail {
  font-size: 0.85rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.queue-actions {
  display: flex;
  gap: 8px;
}

.tone-wait .queue-status {
  color: var(--muted);
}

.tone-busy .queue-status {
  color: var(--green-2);
}

.tone-ok .queue-status {
  color: var(--green);
}

.tone-warn .queue-status {
  color: #8a5a00;
}

.tone-bad .queue-status {
  color: var(--danger);
}

/* 手機：動作鈕換到下一行 */
@media (max-width: 520px) {
  .queue-row {
    grid-template-columns: 56px minmax(0, 1fr);
  }

  .queue-actions {
    grid-column: 2;
  }
}

/* ---- 進貨入庫單 ---- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.receipt-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.receipt-form .card {
  padding: 22px 24px;
}

.card-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--green);
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  margin-bottom: 14px;
}

.card-head .muted {
  font-size: 0.9rem;
}

.rc-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0 16px;
}

.rc-fields label {
  margin-top: 12px;
}

/* 六格一樣大：iPad Safari 的日期、下拉選單預設樣式高低寬窄不一，全部自己畫 */
.rc-fields label > input,
.rc-fields label > select {
  display: block;
  width: 100%;
  height: 48px;
  min-height: 48px;
  margin-top: 6px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background-color: #fff;
  color: var(--text);
  font-size: 16px;
  line-height: 46px;
  -webkit-appearance: none;
  appearance: none;
}

.rc-fields label > select {
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b7068'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

.rc-fields label > input[type="date"]::-webkit-date-and-time-value {
  text-align: left;
  line-height: 46px;
}

.rc-fields label > input:disabled,
.rc-fields label > select:disabled,
.rc-fields label > input[readonly] {
  background-color: var(--cream);
}

.req {
  margin-left: 2px;
  color: var(--alert);
}

input.readonly,
input[readonly] {
  background: var(--cream);
  color: var(--muted);
}

input:disabled,
select:disabled,
textarea:disabled {
  background: #f6f3ec;
  color: var(--text);
  opacity: 1;
  -webkit-text-fill-color: var(--text);
}

textarea {
  resize: vertical;
}

button.small {
  min-height: 40px;
  padding: 6px 12px;
  font-size: 0.9rem;
}

.confirmed-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--green-soft);
  font-weight: 600;
}

.banner {
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--green-soft);
}

.banner-warn {
  background: var(--warn-bg);
  color: #6b4700;
}

.banner-bad {
  background: #fbe4e1;
  color: var(--danger);
}

.banner p {
  margin: 0 0 8px;
}

.banner .tag {
  margin-left: 0;
}

.rc-banners:empty {
  display: none;
}

.rc-banners .banner:last-child {
  margin-bottom: 0;
}

.similar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

/* 品項明細表：表頭淡綠底；窄的時候左右捲動 */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table.lines {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  font-size: 0.95rem;
}

table.lines th {
  padding: 12px 4px;
  background: var(--green-soft);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  text-align: left;
  white-space: nowrap;
}

table.lines th:first-child,
table.lines td:first-child {
  padding-left: 12px;
}

table.lines td {
  padding: 8px 4px;
  vertical-align: top;
}

table.lines tr.line td {
  border-top: 1px solid var(--line);
}

table.lines input {
  min-height: 42px;
  padding: 6px 8px;
}

table.lines input.num {
  text-align: right;
}

table.lines input[aria-invalid="true"] {
  border-color: var(--danger);
  background: #fdf0ee;
}

/* 整行排成一列（Dennis 2026-10-28）：欄寬固定，iPad 1194 寬剛好放得下；更窄時表格自己橫向捲動 */
table.lines {
  table-layout: fixed;
  min-width: 840px;
}

table.lines tr.line td {
  padding: 8px 3px;
}

table.lines tr.line input {
  padding: 6px 6px;
}

table.lines .c-quantity { width: 58px; }
table.lines .c-unit { width: 50px; }
table.lines .c-amount { width: 70px; }
table.lines .c-slip_no { width: 62px; }
table.lines .c-expiry_date { width: 132px; }
table.lines .c-batch_no { width: 82px; }
table.lines .c-location { width: 72px; }
table.lines .c-spec { width: 72px; }
table.lines .c-actions { width: 50px; }
table.lines tr.line:has(.unmatched:not([hidden])) .c-actions,
table.lines:has(.unmatched:not([hidden])) .c-actions { width: 118px; }

.line-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.line-actions .unmatched {
  white-space: nowrap;
  padding: 0 8px;
}

table.lines .slip-no {
  display: block;
  padding: 11px 2px;
  font-size: 0.9rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 需要手動輸入／確認的格子：紅框 */
table.lines input.needs-check {
  border: 2px solid var(--danger);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(179, 38, 30, 0.15);
}

table.lines .c-actions {
  text-align: center;
}

button.icon-button {
  width: 42px;
  min-height: 42px;
  padding: 0;
  font-size: 1.2rem;
  color: var(--muted);
}

button.icon-button:hover {
  color: var(--danger);
  border-color: var(--danger);
}

table.lines tr.flagged td {
  background: var(--warn-bg);
}

table.lines tr.flagged td:first-child {
  box-shadow: inset 4px 0 0 var(--danger);
}

button.unmatched {
  border-color: var(--gold);
  color: #8a5a00;
}

/* 新增品項：虛線框 */
.add-line {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

button.add-line-open {
  width: 100%;
  min-height: 52px;
  border: 1.5px dashed var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--green);
  font-weight: 700;
}

button.add-line-open:hover {
  border-color: var(--green-2);
  background: #fff;
}

.add-line button {
  white-space: nowrap;
}

.empty-lines {
  padding: 18px 12px !important;
  text-align: center;
}

/* 相機掃描出貨單：設計稿的條碼輸入框位置 */
.scan-bar {
  display: flex;
  gap: 14px;
  margin-bottom: 12px;
}

button.scan-field {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 8px 18px;
  border: 2px solid var(--green);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  text-align: left;
}

.scan-icon {
  font-size: 1.2rem;
  color: var(--muted);
}

button.scan-button {
  min-height: 52px;
  padding: 8px 22px;
  border: 1.5px solid var(--green);
  border-radius: 8px;
  background: #fff;
  color: var(--green);
  font-weight: 700;
  white-space: nowrap;
}

button.scan-field:hover,
button.scan-button:hover {
  background: var(--green-soft);
}

/* 每張照片一條：「✓ 已加入「馥豪」・共 N 筆」 */
.scan-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.scan-list:empty {
  display: none;
}

.scan-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 16px 8px 8px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(31, 61, 44, 0.08);
}

.scan-thumb {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  min-height: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: var(--green-soft);
  cursor: zoom-in;
}

span.scan-thumb {
  cursor: default;
}

.scan-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-text {
  flex: 1;
  min-width: 0;
  font-size: 1.02rem;
}

.scan-row.tone-busy .scan-text {
  color: var(--green-2);
}

.scan-row.tone-bad .scan-text {
  color: var(--danger);
}

.scan-row.tone-warn {
  background: var(--warn-bg);
}

.scan-extra {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.scan-extra button.link {
  min-height: 36px;
}

.rc-summary {
  color: var(--muted);
  font-size: 1.05rem;
}

.rc-amount-check {
  display: block;
  margin-top: 4px;
}

.rc-amount-check.warn {
  color: var(--danger);
  font-weight: 600;
}

.rc-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

@media (max-width: 899px) {
  .rc-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

dialog.confirm h2 {
  margin-bottom: 12px;
}

ul.problems {
  margin: 0 0 8px;
  padding-left: 1.2em;
}

/* 選品項 */
dialog.picker {
  max-width: 520px;
}

dialog.picker h3 {
  font-size: 1rem;
  margin: 18px 0 0;
}

.picker-results {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.picker-results li {
  border-bottom: 1px solid var(--line);
}

.picker-results li:last-child {
  border-bottom: none;
}

.picker-results li.muted,
.picker-results li.form-error {
  margin: 0;
  padding: 10px 12px;
}

button.picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  border-radius: 0;
  text-align: left;
}

button.picker-item:hover {
  background: var(--green-soft);
}

.picker-new {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 0 12px;
}

.picker-new label > input,
.picker-new label > select,
dialog label > input,
dialog label > textarea {
  margin-top: 6px;
  color: var(--text);
}

/* 全螢幕照片 */
dialog.viewer {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: none;
  background: #111;
  display: flex;
  flex-direction: column;
}

dialog.viewer:not([open]) {
  display: none;
}

dialog.viewer::backdrop {
  background: #111;
}

.viewer-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  padding-top: max(8px, env(safe-area-inset-top));
  background: #222;
  color: #fff;
}

.viewer-bar button {
  background: #333;
  border-color: #555;
  color: #fff;
}

.viewer-zoom {
  min-width: 4em;
  text-align: center;
}

.viewer-spacer {
  flex: 1;
}

.viewer-stage {
  flex: 1;
  display: flex;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y pinch-zoom;
}

.viewer-img {
  margin: auto;
  flex-shrink: 0;
  max-width: none;
}

@media (max-width: 520px) {
  .rc-fields,
  .picker-new {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---- 入庫紀錄、庫存、品項紀錄 ---- */
.filters {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
}

.range-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.range-seg {
  flex-wrap: wrap;
}

.range-custom {
  display: flex;
  align-items: center;
  gap: 8px;
}

.range-custom input {
  width: auto;
  min-width: 150px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

label.filter {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

label.filter select {
  width: auto;
  min-width: 140px;
  color: var(--text);
}

.cat-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cat-tabs button {
  min-height: 40px;
  padding: 6px 14px;
  border-radius: 20px;
}

.cat-tabs button[aria-pressed="true"] {
  background: var(--green-2);
  border-color: var(--green-2);
  color: #fff;
  font-weight: 600;
}

.search {
  max-width: 360px;
}

.history .section-head h2 .tag {
  vertical-align: middle;
}

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-bottom: 8px;
}

.stock-total {
  margin: 0 0 14px;
}

.history .note {
  margin: 16px 0 0;
  font-size: 0.9rem;
}

@media (max-width: 520px) {
  .range-custom input {
    min-width: 0;
    flex: 1;
  }
}

/* ---- 帳號管理 ---- */
.card.admin + .card.admin {
  margin-top: 20px;
}

dialog.admin-form {
  max-width: 440px;
}

dialog.admin-form label {
  display: block;
  margin-top: 12px;
}

dialog.admin-form label small {
  display: block;
  margin-top: 4px;
}

td.row-actions {
  text-align: right;
}

td.row-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 4px;
}

/* ---- 薪資費用（五步） ---- */
.payroll-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 18px;
  margin-bottom: 8px;
}

.payroll-progress {
  font-weight: 600;
}

.payroll-notice {
  margin: 8px 0;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}

.payroll-notice.warn {
  background: var(--warn-bg);
  border-color: var(--gold-line);
}

.payroll-notice ul {
  margin: 6px 0 0;
  padding-left: 20px;
}

.pill-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 12px 0;
}

.pill-tabs .pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 999px;
  white-space: nowrap;
}

.pill-tabs .pill.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.pill-mark {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green);
  font-size: 0.85rem;
  font-weight: 600;
}

.pill-tabs .pill.done .pill-mark {
  background: var(--green-2);
  color: #fff;
}

.amount-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.amount-row input {
  flex: 1 1 8rem;
}

.amount-row select {
  flex: 0 0 6rem;
  width: auto;
}

.schedule-grid {
  border-collapse: collapse;
  font-size: 0.85rem;
}

.schedule-grid th,
.schedule-grid td {
  border: 1px solid var(--line);
  padding: 0;
  text-align: center;
  background: var(--card);
}

.schedule-grid thead th {
  padding: 4px 2px;
  min-width: 44px;
  font-weight: 500;
}

.schedule-grid thead th.d0,
.schedule-grid thead th.d6 {
  background: var(--green-soft);
}

.schedule-grid tbody th {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 7rem;
  padding: 4px 8px;
  text-align: left;
  font-weight: 500;
}

.week-warning {
  font-size: 0.75rem;
  color: var(--danger);
  white-space: nowrap;
}

button.cell {
  width: 44px;
  min-height: 44px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 0;
  background: transparent;
}

/* 上班的格子寫時間（09:30–13:30），字小一點、兩段班就兩行；休假類的格子寫字、底色淡 */
button.cell.work {
  width: 52px;
  padding: 2px 1px;
  font-size: 0.68rem;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}

button.cell.off {
  color: var(--muted);
  background: #f3efe7;
}

/* 這天改過時間、或排了別的班：和固定班不同底色（測試紀錄第 11 點） */
button.cell.own {
  background: var(--green-soft);
}

/* 格子上的請假（事2、病）和加班（加2） */
.cell-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1px;
  margin-top: 1px;
}

.cell-tag {
  border-radius: 3px;
  padding: 0 2px;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1.3;
}

.cell-tag.leave {
  background: #fde4dc;
  color: var(--terracotta-dark);
}

.cell-tag.ot {
  background: var(--warn-bg);
  color: #8a6a10;
}

button.cell.changed {
  border-color: var(--terracotta);
  background: var(--warn-bg);
  font-weight: 700;
}

.anomaly {
  margin-bottom: 12px;
}

.anomaly.decided {
  border-left: 4px solid var(--green-2);
}

.anomaly-who {
  font-size: 0.85rem;
  color: var(--muted);
}

.anomaly-title {
  font-weight: 600;
}

.anomaly-choices button {
  flex: 1 1 12rem;
}

.anomaly-done {
  margin-top: 6px;
  color: var(--green-2);
}

.import-ok {
  color: var(--green-2);
}

table.list td.how {
  color: var(--muted);
  font-size: 0.85rem;
}

table.list tr.group td,
table.list tr.total td {
  font-weight: 600;
  background: var(--green-soft);
}

.lock-bar .actions {
  flex-wrap: wrap;
}

/* 薪資單：照工資清冊把每一項都列出來，金額 0 的淡掉，有數字的才跳出來。
   排得很緊（Dennis 2026-10-28）：iPad 11 吋橫放一頁看完——時數五欄，領項、扣項左右並排，列高壓低 */
.slip {
  font-size: 0.88rem;
}

.slip .slip-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 14px;
}

.slip .slip-title .card-title {
  margin: 0;
}

.slip .slip-title a.button {
  margin-left: auto;
}

.slip .slip-head {
  margin: 0.6rem 0 0.2rem;
  font-size: 0.9rem;
}

.slip .slip-head .muted {
  font-weight: 400;
  margin-left: 4px;
}

.slip table.list tr.zero td,
.slip .slip-hours div.zero {
  color: var(--muted);
}

.slip .slip-hours {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0 0.9rem;
  font-size: 0.82rem;
}

.slip .slip-hours div {
  display: flex;
  justify-content: space-between;
  gap: 0.4rem;
  padding: 2px 0;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.slip .slip-cols {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 0.7rem;
  align-items: start;
}

.slip table.list {
  table-layout: fixed;
  width: 100%;
}

.slip table.list th,
.slip table.list td {
  padding: 3px 6px;
  line-height: 1.35;
}

.slip table.list th:first-child,
.slip table.list td:first-child {
  width: 34%;
}

.slip table.list th:nth-child(2),
.slip table.list td:nth-child(2) {
  width: 22%;
}

.slip table.list td.how {
  font-size: 0.75rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.slip table.list tr.total td {
  font-weight: 700;
}

.slip .slip-net {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px 16px;
  margin-top: 0.6rem;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--green-soft);
}

.slip .slip-net b {
  font-size: 1.15rem;
}

@media (max-width: 899px) {
  .slip .slip-hours {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .slip .slip-cols {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* 法規提醒收起來之後的深綠色圓點：擺在「修改資料」左邊，提醒人資它還在 */
.law-dot {
  /* 全站的 button 有 min-height:44px，不蓋掉會被拉成橢圓 */
  width: 12px;
  height: 12px;
  min-height: 12px;
  min-width: 12px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--green-2);
  cursor: pointer;
  align-self: center;
  flex: 0 0 auto;
}

.law-dot:hover,
.law-dot:focus-visible {
  outline: 2px solid var(--green-2);
  outline-offset: 2px;
}

/* 廠區篩選：平常只有「全部」「選廠區」兩顆，展開才列廠區 */
.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chips-depts {
  margin-top: 8px;
}

.chip-caret {
  font-size: 0.75em;
}

/* 異常確認：一筆一列，按鈕在右邊；送出固定在分頁列右邊的空位 */
/* pill 列會橫向捲動，送出按鈕要放在捲動區外面才不會被切掉 */
.tabs-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tabs-row .pill-tabs {
  flex: 1;
  min-width: 0;
}

.tabs-extra {
  margin-left: auto;
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}

.tabs-extra button {
  white-space: nowrap;
}

.anomaly-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--line);
}

.anomaly-row:hover {
  background: var(--green-soft);
}

.anomaly-row .anomaly-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.15rem 0.6rem;
}

.anomaly-row .anomaly-who {
  font-weight: 600;
  min-width: 5rem;
}

.anomaly-row .anomaly-title {
  font-weight: 500;
}

.anomaly-row .anomaly-choices {
  display: flex;
  gap: 0.4rem;
  flex: 0 0 auto;
}

button.mini {
  padding: 0.25rem 0.7rem;
  font-size: 0.85rem;
  white-space: nowrap;
}

button.mini.chosen {
  border-color: var(--green-2);
  color: var(--green-2);
}

.anomaly-row.staged {
  background: var(--green-soft);
}

@media (max-width: 720px) {
  .anomaly-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
  }
}

/* ---- 薪資費用：分頁列、員工資料與計薪規則 ---- */
.payroll-tabs {
  margin-top: 0;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.staff-head {
  align-items: center;
  gap: 8px 12px;
}

/* 月份切換「‹ 2026 年 10 月 ›」：分頁列「公司設定」後面（測試紀錄 #1、#6） */
.payroll-tabs .month-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  margin-left: 12px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.payroll-tabs .month-bar button {
  min-width: 44px;
  padding: 8px 0;
}

.payroll-tabs .month-label {
  min-width: 7.5em;
  text-align: center;
  white-space: nowrap;
}

.staff-layout {
  display: grid;
  grid-template-columns: minmax(240px, 300px) 1fr;
  gap: 16px;
  align-items: start;
}

@media (max-width: 800px) {
  .staff-layout {
    grid-template-columns: 1fr;
  }
}

.staff-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  min-height: 44px;
  padding: 6px 14px;
  border-radius: 999px;
}

.chip.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.check-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  min-height: 44px;
}

.check-line input {
  width: 24px;
  min-height: 24px;
}

.staff-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 60vh;
  overflow-y: auto;
}

.staff-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  flex-shrink: 0; /* 清單有 max-height 會捲動：不縮，卡片才包得住裡面的字 */
  gap: 2px;
  min-height: 56px;
  padding-right: 92px; /* 右上角留給「N 項提醒」 */
  text-align: left;
  width: 100%;
}

/* 「N 項提醒」放卡片右上角（測試紀錄 #5：原本壓在左下框線上） */
.staff-item .tag-alert {
  position: absolute;
  top: 8px;
  right: 8px;
  margin-left: 0;
}

.staff-item.active {
  border-color: var(--green);
  background: var(--green-soft);
}

.staff-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.tag-alert {
  background: var(--danger);
  color: #fff;
}

.law-banner {
  margin: 8px 0 12px;
  padding: 12px 16px;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  background: #fdeceb;
  color: var(--danger);
}

.law-banner ul {
  margin: 6px 0;
  padding-left: 20px;
}

.law-banner p {
  margin: 6px 0;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px 20px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field.wide-field {
  grid-column: 1 / -1;
}

.field-label {
  font-size: 0.9rem;
  color: var(--muted);
}

.field-value {
  min-height: 44px;
  display: flex;
  align-items: center;
}

.field-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.grade-stepper {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.grade-stepper button {
  min-width: 44px;
}

.grade-value {
  min-width: 6em;
  text-align: center;
  font-weight: 600;
}

.allowance-row,
.block-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.allowance-row input {
  width: 9em;
}

.block-row input[type="time"] {
  width: 8em;
}

.day-toggles {
  display: flex;
  gap: 4px;
}

.day-toggle {
  min-width: 44px;
  padding: 8px 0;
}

.day-toggle.on {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.blocks {
  margin: 0;
  padding-left: 20px;
}

.blocks small,
.block-row small {
  display: block;
  width: 100%;
}

.change-summary {
  margin: 8px 0;
  padding-left: 20px;
}

dialog.save-dialog .save-explain {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--warn-bg);
  white-space: normal;
}

dialog.admin-form textarea {
  width: 100%;
}

.log-table td {
  vertical-align: top;
}

/* ---- 薪資費用：公司設定 ---- */
.config-subtabs {
  margin-top: 0;
}

.config-body h2 {
  margin-top: 20px;
}

.config-field {
  display: grid;
  gap: 4px;
  max-width: 28em;
  margin: 12px 0;
}

.config-field input,
.config-field select {
  min-height: 44px;
}

.config-chip-list {
  list-style: none;
  padding: 0;
  margin: 8px 0;
  align-items: center;
}

.config-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
}

.chip-remove {
  min-width: 44px;
  min-height: 44px;
  border-radius: 999px;
}

.chip-remove:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.config-add {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.config-add input,
.config-add button,
.config-shifts input {
  min-height: 44px;
}

.config-note {
  padding: 10px 14px;
  border-left: 4px solid var(--line);
  background: rgba(0, 0, 0, 0.04);
  max-width: 40em;
}

.config-blocked ul {
  margin: 4px 0 4px 1.2em;
}

.config-save {
  margin: 16px 0;
  align-items: center;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
}

.switch-row input[type="checkbox"] {
  width: 28px;
  height: 28px;
  flex: none;
}

.access-list {
  list-style: none;
  padding: 0;
  margin: 8px 0;
}

.access-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  border-bottom: 1px solid var(--line);
}

.law-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 24px;
  margin: 12px 0;
}

.law-list dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.law-grades {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0;
}

.law-grades li {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
}

/* ---- 設計預覽頁（public/js/views/preview/）：還沒做的功能，照設計稿畫的假資料畫面 ---- */
.nav-preview {
  margin-left: auto;
  padding: 0 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.75);
  font-size: 11px;
  font-weight: 400;
  line-height: 18px;
}

.pv-page > * + * {
  margin-top: 14px;
}

.pv-banner {
  margin: 0;
  font-size: 0.9rem;
}

.pv-note {
  font-size: 0.9rem;
}

/* 原型的【工程師備註】：虛線框，畫面上一看就知道不是給使用者看的 */
.pv-devnote {
  padding: 8px 12px;
  border: 1px dashed #7a6cc4;
  border-radius: 8px;
  background: #f4f2fc;
  color: #3d3470;
  font-size: 0.85rem;
}

.pv-devnote b {
  margin-right: 8px;
}

.pv-cards {
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr));
  gap: 14px;
}

.pv-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
}

.pv-card-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.pv-card-value {
  margin-top: 2px;
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--green);
}

.pv-card-sub {
  font-size: 0.8rem;
  color: var(--muted);
}

.pv-warn {
  background: #fdebc8;
  border-color: #f3d79a;
}

.pv-warn .pv-card-value {
  color: #8c5a0e;
}

.pv-bad {
  background: #f6ddd3;
  border-color: #ecc0ae;
}

.pv-bad .pv-card-value {
  color: var(--alert);
}

.pv-muted .pv-card-value {
  color: var(--muted);
}

.pv-dark .pv-card-value {
  color: var(--text);
}

.pv-panel .pv-head {
  align-items: center;
}

.pv-head-right {
  margin-left: auto;
}

.pv-step,
.pv-num {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.pv-num {
  width: 20px;
  height: 20px;
  margin-right: 6px;
  font-size: 11px;
}

.pv-grid2,
.pv-grid3 {
  display: grid;
  gap: 12px 18px;
}

.pv-grid2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.pv-grid3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.pv-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
}

.pv-label {
  display: flex;
  align-items: center;
  font-size: 0.9rem;
  color: var(--muted);
}

.pv-readonly {
  background: #f5f1e7;
  color: var(--muted);
}

.pv-table table.list th {
  background: var(--green-soft);
  color: #4d554a;
}

.pv-table table.list td {
  vertical-align: middle;
}

.pv-table table.list th.num {
  text-align: right;
}

.pv-page button {
  white-space: nowrap;
}

.pv-table input,
.pv-table select {
  min-height: 38px;
  padding: 6px 10px;
}

.pv-foot td {
  font-weight: 700;
  background: #f6f1e6;
}

.pv-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.pv-pill-ok {
  background: var(--green-soft);
  color: var(--green);
}

.pv-pill-warn {
  background: #fdebc8;
  color: #8c5a0e;
}

.pv-pill-bad {
  background: #f6ddd3;
  color: var(--alert);
}

.pv-pill-draft {
  background: #e2ecee;
  color: #5e8590;
}

.pv-pill-dark {
  background: #e4e4e0;
  color: var(--text);
}

.pv-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pv-panel .pv-footer {
  margin-top: 16px;
}

.pv-footer-btns {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.pv-footer .pv-footer-btns {
  margin-top: 0;
}

.pv-add {
  width: 100%;
  margin-top: 12px;
  border: 1.5px dashed var(--line);
  color: var(--green);
  font-weight: 700;
  background: #fff;
}

.pv-neg {
  color: var(--alert);
  font-weight: 700;
}

.pv-pos {
  color: #8c5a0e;
  font-weight: 700;
}

.pv-count {
  max-width: 140px;
}

.pv-count[aria-invalid="true"] {
  border-color: var(--danger);
  background: #fdf0ee;
}

/* 盤點：數量格子後面接單位 */
.pv-count-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.pv-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.pv-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 14px;
  align-items: start;
}

.pv-split > * {
  margin: 0 !important;
}

.pv-split-even {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.pv-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pv-thumb {
  width: 48px;
  height: 62px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: repeating-linear-gradient(#fff 0 8px, #e7e2d6 8px 10px);
}

.pv-calc .pv-calc-final {
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
}

dialog.pv-dialog {
  width: min(760px, 94vw);
  padding: 20px 24px;
  border: none;
  border-radius: 16px;
}

dialog.pv-dialog::backdrop {
  background: rgba(37, 48, 42, 0.45);
}

/* 窄螢幕（iPad 直放）：多欄的格子變少欄 */
/* 品項詳情（原型 Item） */
.pv-it-search {
  display: flex;
  gap: 10px;
}

.pv-it-search .pv-it-q {
  flex: 1;
  max-width: 420px;
}

.pv-it-real {
  margin-left: auto;
  align-self: center;
  font-size: 0.9rem;
}

.pv-it-results {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pv-it {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pv-it-top {
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
}

.pv-it-info {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 20px;
  margin: 0;
}

.pv-it-info dt {
  font-size: 0.85rem;
  color: var(--muted);
}

.pv-it-info dd {
  margin: 2px 0 0;
}

.pv-it-stock b {
  font-size: 2.6rem;
  line-height: 1.1;
  margin-right: 6px;
}

.pv-it-bad b {
  color: var(--danger);
}

.pv-it-warn b {
  color: #8a5a00;
}

.pv-it-meter {
  height: 10px;
  margin: 10px 0 6px;
  border-radius: 99px;
  background: var(--line);
  overflow: hidden;
}

.pv-it-meter span {
  display: block;
  height: 100%;
  background: var(--danger);
}

.pv-it-ok + .pv-it-meter span {
  background: var(--green);
}

.pv-it-hint {
  margin: 0 0 12px;
  font-size: 0.85rem;
}

.pv-it-actions {
  display: flex;
  gap: 10px;
}

a.button.primary {
  background: var(--terracotta);
  border-color: transparent;
  color: #fff;
}

.pv-it-sup {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.pv-it-ops {
  display: inline-flex;
  gap: 6px;
}

/* 盤點：手動輸入品項 */
.pv-ct-add {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 0 12px;
}

.pv-ct-add-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pv-ct-add-row input {
  width: 130px;
}

@media (max-width: 1000px) {.pv-grid3 {
    grid-template-columns: minmax(0, 1fr);
  }

  .pv-split,
.pv-split-even {
    grid-template-columns: minmax(0, 1fr);
  }

  .pv-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}



/* 班表上方：說明文字和「第一週複製到第二週／還原／儲存」排成一列，文字在左邊自動換行（Dennis 2026-10-28） */
.card.schedule-bar {
  display: flex;
  align-items: center;
  gap: 16px;
}

.schedule-bar > p {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
}

.schedule-bar > .actions {
  flex: none;
  align-items: center;
  margin-top: 0;
}

/* 營業成本（#/cost）：合計一行、依供應商／分類／月份的小表並排，下面是帳單明細 */
.cost-total {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  margin: 12px 0;
  font-size: 15px;
}

.cost-total b {
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

.cost-breakdowns {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 8px;
}

.cost-breakdown {
  flex: 1 1 240px;
  min-width: 0;
}

.cost-breakdown h3,
.cost-bills-title {
  margin: 8px 0 4px;
  font-size: 15px;
}

.cost-breakdown .num,
.history td.num .tag {
  font-variant-numeric: tabular-nums;
}

.history td.num .tag {
  margin-left: 6px;
}

/* 總覽 › 營業成本查詢：品項比價、進貨金額走勢（cost-query.js、line-chart.js） */
.history h3 {
  margin: 16px 0 6px;
  font-size: 15px;
}

.cost-cheapest {
  margin: 4px 0 10px;
  font-weight: 700;
  color: var(--green-2);
}

.swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 6px;
  border-radius: 3px;
  vertical-align: -1px;
}

td.delta-up {
  color: #a3462a;
}

td.delta-down {
  color: var(--green-2);
}

.line-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 4px 0;
  font-size: 13px;
}

.line-legend-key i {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 6px;
  border-radius: 3px;
  vertical-align: -1px;
}

.line-chart svg {
  display: block;
  width: 100%;
  max-width: 760px;
  height: auto;
}

.history tfoot td {
  border-top: 2px solid var(--line, #e6dfd2);
}
