/* 支出與損益(店務分頁 + 設定卡的類別表)。顏色與圓角用 app.css 的變數;金額一律靠右等寬數字。 */
#expenses-root { display: flex; flex-direction: column; gap: 12px; }
.exp-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.exp-tool { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #556; }
.exp-tool input, .exp-tool select { min-height: 40px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; background: #fff; color: var(--ink); }
.exp-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.exp-seg button { min-height: 40px; padding: 0 16px; border: 0; background: #fff; color: var(--ink); font-size: 15px; cursor: pointer; }
.exp-seg button + button { border-left: 1px solid var(--line); }
.exp-seg button.active { background: var(--sel-bg); color: var(--sel-fg); }
.exp-bar .primary, .exp-bar .secondary { min-height: 40px; }
.exp-spacer { flex: 1; }
.exp-err { background: #fff5f5; border: 1px solid #f3b1b1; color: var(--warn); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.exp-empty { background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); padding: 28px 16px; text-align: center; color: #556; }
.exp-empty p { margin: 0 0 8px; font-size: 16px; }
.exp-empty .hint { font-size: 14px; }
.exp-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.exp-card h3 { margin: 0 0 8px; font-size: 17px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.exp-card h3 small { font-size: 13px; color: #667; font-weight: normal; }
.exp-note { font-size: 13px; color: #667; margin: 6px 0 0; }
.exp-warn { font-size: 13px; color: var(--amber); margin: 6px 0 0; }
table.exp-tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
table.exp-tbl th, table.exp-tbl td { padding: 8px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.exp-tbl th { font-size: 13px; color: #556; font-weight: 600; white-space: nowrap; }
table.exp-tbl td.num, table.exp-tbl th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.exp-tbl tr.exp-sum td { font-weight: 700; border-top: 2px solid var(--ink); }
table.exp-tbl tr.exp-gross td, table.exp-tbl tr.exp-net td { background: #f7f8fb; }
table.exp-tbl tr.exp-net td { font-size: 17px; }
table.exp-tbl td.neg { color: var(--warn); }
.exp-up { color: var(--ok); } .exp-down { color: var(--warn); } .exp-flat { color: #667; }   /* 灰字至少 4.5:1 */
table.exp-tbl tr.exp-del td { color: #667; text-decoration: line-through; }
table.exp-tbl tr.exp-del td.exp-act, table.exp-tbl tr.exp-del td .exp-reason { text-decoration: none; }
.exp-reason { display: block; font-size: 12px; color: #667; }
.exp-src { display: inline-block; font-size: 12px; color: var(--accent); white-space: nowrap; }   /* 來源字樣:只用顏色,不再是卡片裡的小方塊 */
.exp-act { white-space: nowrap; }
.exp-act button { min-height: 34px; padding: 0 10px; margin-right: 4px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); font-size: 13px; cursor: pointer; }
.exp-act button.danger { color: var(--warn); border-color: #f3b1b1; }
.exp-act a { font-size: 13px; }
.exp-list-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; font-size: 13px; color: #556; }
.exp-list-foot label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
/* 記一筆 / 改一筆的視窗 */
.exp-form { display: flex; flex-direction: column; gap: 12px; }
.exp-form label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.exp-form input, .exp-form select, .exp-form textarea { min-height: 42px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 16px; }
.exp-form textarea { min-height: 64px; resize: vertical; }
.exp-form .exp-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.exp-photo { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.exp-photo img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.exp-photo .hint { font-size: 13px; }
.exp-dup { background: #fff8e6; border: 1px solid #f5d58a; border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.exp-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.exp-actions button { min-height: 42px; padding: 0 16px; }
.exp-hist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow: auto; }
.exp-hist li { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 14px; }
.exp-hist .when { color: #667; font-size: 12px; }
.exp-hist .chg { margin: 2px 0 0 0; padding-left: 16px; }
/* 設定卡:類別表 */
.exp-cats { display: flex; flex-direction: column; gap: 6px; margin: 6px 0; }
.exp-cat { display: grid; grid-template-columns: minmax(120px, 1fr) auto auto auto auto; gap: 8px; align-items: center; }
.exp-cat input[type="text"] { min-height: 38px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; }
.exp-cat label { display: inline-flex !important; flex-direction: row !important; align-items: center; gap: 4px; font-size: 13px !important; white-space: nowrap; }
.exp-cat button { min-height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--warn); font-size: 13px; cursor: pointer; }
.exp-cat .exp-cat-fixed { font-size: 12px; color: #667; }
@media (max-width: 640px) {
  .exp-bar { padding: 8px 10px; }
  .exp-seg button { padding: 0 12px; }
  table.exp-tbl { font-size: 14px; }
  table.exp-tbl th, table.exp-tbl td { padding: 7px 5px; }
  .exp-form .exp-row2 { grid-template-columns: 1fr; }
  .exp-cat { grid-template-columns: 1fr 1fr; }
  .exp-cat .exp-cat-name { grid-column: 1 / -1; }
  .exp-cat label { font-size: 12px !important; }
  .exp-hide-sm { display: none; }
  /* 支出清單:一筆一張小卡(日期 · 類別 · 金額 / 備註 / 按鈕),不再用擠成一團的表格欄 */
  table.exp-list thead { display: none; }
  table.exp-list tbody tr { display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "date cat amt" "note note note" "act act act"; gap: 3px 8px; padding: 9px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
  table.exp-list td { display: block; border: 0; padding: 0; }
  table.exp-list td.c-date { grid-area: date; color: #556; font-size: 13px; white-space: nowrap; }
  table.exp-list td.c-cat { grid-area: cat; font-weight: 600; }
  table.exp-list td.c-amt { grid-area: amt; font-weight: 700; }
  table.exp-list td.c-note { grid-area: note; color: #445; font-size: 14px; }
  table.exp-list td.c-by { display: none; }
  table.exp-list td.exp-act { grid-area: act; text-align: right; }
  table.exp-list td.exp-act:empty { display: none; }
  table.exp-list tr.exp-sum { grid-template-areas: "date cat amt"; border-top: 2px solid var(--ink); }
  table.exp-list tr.exp-sum td { border-top: 0; }   /* 合計的粗線畫在整列上,不是每一格各畫一段 */
  table.exp-list tr.exp-sum td.c-date { color: var(--ink); font-size: 15px; font-weight: 700; }
  table.exp-list tr.exp-sum td.c-note, table.exp-list tr.exp-sum td.exp-act { display: none; }
  /* 整列可點(public/row-actions.css)在小卡排法:底色畫在整張卡上(不是一格一塊),右緣的「›」不放(最後一格是按鈕,會疊在按鈕上) */
  table.exp-list tr[data-row-act]:hover > td, table.exp-list tr[data-row-act]:active > td { background: transparent; }
  table.exp-list tr[data-row-act]:hover { background: #fff7ed; }
  table.exp-list tr[data-row-act]:active { background: #ffe8d1; }
  table.exp-list tr[data-row-act] > td:last-child::after { display: none; }
}
/* 關帳視窗的「今天的支出」(public/close-expenses-ui.js):預設只有一顆展開鈕與一行小字,展開後每個類別一小列 */
.modal .cdx-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.modal .cdx-toggle { min-height: 44px; padding: 0 16px; }
.modal .cdx-sum { flex: 1 1 140px; min-width: 0; margin: 0; }
.modal .cdx-list { display: flex; flex-direction: column; gap: 8px; }
.modal .cdx-row { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.modal .cdx-row.cdx-bad { border-color: #f3b1b1; }
.modal .cdx-name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.modal .cdx-name small { font-size: 12.5px; color: var(--muted); }
.modal .cdx-name small.cdx-ok { color: #166534; font-weight: 700; }
.modal .cdx-fields { display: flex; flex-wrap: wrap; gap: 8px; }
.modal .cdx-fields input { min-height: 44px; box-sizing: border-box; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 16px; min-width: 0; }
.modal .cdx-amt { flex: 0 0 8.5em; width: 8.5em; text-align: right; font-variant-numeric: tabular-nums; }
.modal .cdx-note { flex: 1 1 9em; }
.modal .cdx-photo { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 8px; }
.modal .cdx-photo img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.modal .cdx-photo button, .modal .cdx-photobtn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 14px; box-sizing: border-box; border: 1px solid var(--line); border-radius: 8px; background: #eef1f5; color: var(--ink); font-size: 15px; cursor: pointer; white-space: nowrap; }
.modal .cdx-err { color: var(--warn); font-size: 13.5px; font-weight: 700; line-height: 1.45; }
