/* 員工月結頁專用樣式；共用元件見 /styles.css。 */

/* 上方工具列 */
.ledger-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ledger-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.ledger-chips:empty { display: none; }
.ledger-chips .dotchip { font-size: 12px; padding: 4px 11px; }
.ledger-steps { margin-left: auto; display: flex; gap: 6px; }

/* 總覽：切換依員工／全部明細，員工卡片 */
.card-head .ledger-head-total { font-size: 13px; }
.ledger-head-total strong { color: var(--ink); font-size: 15px; font-weight: 900; }
.ledger-emps { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; padding: 16px 18px; }
.ledger-emp {
  position: relative; display: flex; flex-direction: column; gap: 2px; min-width: 0;
  border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: var(--card);
  text-align: left; color: inherit; font: inherit;
}
.ledger-emp:hover { border-color: var(--accent); box-shadow: var(--shadow-s); }
.ledger-emp.has-miss::after {
  content: ""; position: absolute; top: 14px; right: 14px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--blue); box-shadow: 0 0 0 3px var(--blue-s);
}
.ledger-emp-name { display: flex; align-items: center; gap: 6px; min-width: 0; padding-right: 16px; }
.ledger-emp-name strong { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ledger-emp-name .tag { padding: 1px 8px; font-size: 11px; }
.ledger-emp-count { font-size: 12px; color: var(--muted); }
.ledger-emp-amt { margin-top: 8px; font-size: 21px; font-weight: 900; line-height: 1.25; }
.ledger-emp-amt .muted { font-size: 15px; font-weight: 700; }
.ledger-emp-miss { font-size: 12px; font-weight: 700; color: var(--blue); }
.ledger-emp-ok { font-size: 12px; font-weight: 700; color: var(--done); }
.ledger-idle { margin: 0; padding: 0 18px 14px; font-size: 12px; color: var(--muted); }

/* 批次填單價 */
.ledger-batch { display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap; padding: 10px 18px; }
.ledger-batch.inset { background: var(--soft); border-bottom: 1px solid var(--line); }
.ledger-batch > strong { font-size: 13px; }
.ledger-batch select { width: auto; min-width: 180px; max-width: 100%; height: 34px; padding: 0 10px; }
.ledger-batch .ledger-price { height: 34px; background: var(--card); border-color: var(--line); }
.ledger-batch .button.small { height: 34px; padding: 0 14px; }
.ledger-batch small { color: var(--muted); font-size: 12px; }
.ledger-batch .ledger-price input { text-align: left; }
.ledger-batch .ledger-price input::placeholder { color: var(--muted); }

/* 單價輸入：$ 前綴、數字靠右；空白時標示待填 */
.ledger-price {
  display: inline-flex; align-items: center; gap: 2px; padding: 0 6px; font-weight: 500;
  border: 1px solid var(--line); border-radius: 8px; background: var(--card); vertical-align: middle;
  transition: border-color .15s, background-color .15s;
}
.ledger-price > span { margin: 0; font-size: 13px; color: var(--muted); }
.ledger-price input { width: 76px; border: 0; padding: 4px 2px; background: transparent; text-align: right; -moz-appearance: textfield; }
.ledger-price input:focus { box-shadow: none; }
.ledger-price input::-webkit-inner-spin-button, .ledger-price input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.ledger-price input::placeholder { color: var(--blue); opacity: .8; }
.ledger-price:hover, .ledger-price:focus-within { border-color: var(--accent); }
.ledger-price.miss { border-style: dashed; border-color: color-mix(in srgb, var(--blue) 55%, var(--line)); background: var(--blue-s); }
.ledger-price.is-saving { opacity: .6; }
.ledger-price.is-saved { border-style: solid; border-color: var(--done); background: var(--done-s); }
.ledger-price.is-failed { border-style: solid; border-color: var(--red); background: var(--red-s); }

/* 明細 */
.ledger-sh-id { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ledger-sh-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.ledger-total { display: flex; align-items: baseline; gap: 8px; }
.ledger-total small { font-size: 12px; color: var(--muted); font-weight: 700; }
.ledger-card > .table-wrap { border-radius: 0 0 13px 13px; }
.ledger-table { min-width: 680px; }
.ledger-table.with-emp { min-width: 800px; }
.ledger-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.ledger-emp-cell { white-space: nowrap; }
.ledger-emp-cell .tag { margin-left: 6px; padding: 1px 8px; font-size: 11px; }
.ledger-date { white-space: nowrap; }
.ledger-sub { display: block; font-size: 12px; color: var(--muted); }
.ledger-work small { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }
.ledger-work .ledger-exception { color: var(--red); }
.ledger-work .midway-tag { margin-left: 6px; }
.ledger-task { border: 0; background: none; padding: 0; font: inherit; font-weight: 700; color: inherit; text-align: left; }
.ledger-task:hover { color: var(--accent-d); text-decoration: underline; }
.ledger-amount { font-weight: 700; }
.ledger-foot-note { margin-left: 10px; font-size: 12px; font-weight: 700; color: var(--blue); }

@media (max-width: 900px) {
  .ledger-steps { margin-left: 0; }
  .ledger-emps { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 12px; }
  .ledger-emp { padding: 12px 14px; }
  .ledger-batch { padding: 10px 14px; }
  .ledger-batch select { flex: 1 1 100%; }
  .ledger-card > .card-head .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .card-head .ledger-head-total { width: 100%; }
  .ledger-total strong { font-size: 22px; }
}

/* 手機：明細每筆改成上下排列，單價欄不必左右捲動 */
@media (max-width: 640px) {
  .ledger-table, .ledger-table.with-emp { min-width: 0; }
  .ledger-table thead { display: none; }
  .ledger-table, .ledger-table tbody, .ledger-table tfoot { display: block; }
  .ledger-table tbody tr {
    display: grid; grid-template-columns: auto minmax(0, 1fr) 84px; align-items: center; gap: 6px 12px;
    grid-template-areas: "date case case" "work work work" "qty price amt";
    padding: 12px 16px; border-bottom: 1px solid var(--line);
  }
  .ledger-table.with-emp tbody tr { grid-template-areas: "emp emp date" "case case case" "work work work" "qty price amt"; }
  .ledger-emp-cell { grid-area: emp; min-width: 0; font-size: 15px; }
  .ledger-table.with-emp .ledger-date { justify-self: end; font-weight: 500; color: var(--muted); }
  .ledger-table tbody tr.ledger-empty-row { display: block; }
  .ledger-table tbody td { padding: 0; border: 0; }
  .ledger-date { grid-area: date; font-weight: 700; }
  .ledger-case { grid-area: case; min-width: 0; }
  .ledger-case .ledger-sub { display: inline; margin-left: 6px; }
  .ledger-work { grid-area: work; }
  .ledger-table td.ledger-qty { grid-area: qty; text-align: left; color: var(--muted); }
  .ledger-price-cell { grid-area: price; justify-self: end; }
  .ledger-amount { grid-area: amt; }
  .ledger-table tfoot tr { display: flex; justify-content: space-between; gap: 12px; background: var(--soft); }
  .ledger-table tfoot td { padding: 12px 16px; }
  .ledger-foot-note { display: block; margin: 2px 0 0; }
}
