/* PostWatch — Batch manning, screen styles
   ============================================================================
   A data-entry table someone works down for several minutes at a time, often
   on a phone, sometimes outdoors. The layout is built around that: large
   targets, figures that line up, and a footer that always says how many rows
   are answered and what the save will do.
   ========================================================================== */

.bm-page {
  display: grid;
  gap: 1rem;
  padding-bottom: 2rem;
}

.bm-page [hidden] { display: none; }

.bm-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  font-size: 14px;
  color: var(--pw-text-muted, #6b6862);
}

.bm-pagination .btn { min-width: 44px; min-height: 44px; }
.bm-input[aria-invalid="true"] { border-color: var(--pw-crit, #b42318); }

/* --------------------------------------------------------------- controls */

.bm-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: end;
}

.bm-field {
  display: grid;
  gap: 0.375rem;
  min-width: 0;
  flex: 1 1 12rem;
  max-width: 22rem;
}

.bm-field > span {
  font-size: 14px;
  font-weight: 600;
  color: var(--pw-text-muted, #6b6862);
}

.bm-field :where(select, input) {
  width: 100%;
  min-height: 44px;
  font-size: max(16px, 1rem);
}

.bm-toggle {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  min-height: 44px;
  font-size: 14px;
  color: var(--pw-text, #14140f);
  cursor: pointer;
}

.bm-toggle input {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.bm-scope {
  margin: 0;
  font-size: 14px;
  color: var(--pw-text-muted, #6b6862);
}

/* ------------------------------------------------------------------ table */

.bm-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--pw-border, #e8e6e0);
  border-radius: var(--pw-radius-card, 16px);
  background: var(--pw-surface, #fff);
}

.bm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.bm-table caption { text-align: left; }

.bm-table th,
.bm-table td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--pw-border, #e8e6e0);
  text-align: left;
  vertical-align: middle;
}

.bm-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--pw-surface, #fff);
  border-bottom: 2px solid var(--pw-border, #e8e6e0);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--pw-text-muted, #6b6862);
}

.bm-table tbody tr:last-child th,
.bm-table tbody tr:last-child td { border-bottom: 0; }

.bm-table tbody th { font-weight: 600; }
.bm-table tbody th strong { display: block; font-weight: 700; }

/* Figures line up so a person scanning the column sees the shape of the day. */
.bm-num { text-align: right; font-variant-numeric: tabular-nums; }
.bm-table td.bm-num,
.bm-table th.bm-num { text-align: right; }

.bm-input {
  width: 5rem;
  min-height: 44px;
  padding: 0.375rem 0.5rem;
  border: 1px solid var(--pw-border, #e8e6e0);
  border-radius: var(--pw-radius-control, 12px);
  background: var(--pw-surface, #fff);
  color: var(--pw-text, #14140f);
  font-size: max(16px, 1rem);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.bm-input:focus-visible {
  outline: 2px solid var(--pw-focus, #2563eb);
  outline-offset: 1px;
}

.bm-saved-flag,
.bm-dup-flag {
  display: block;
  margin-top: 2px;
  font-size: 14px;
  font-weight: 500;
}
.bm-saved-flag { color: var(--pw-text-muted, #6b6862); }
.bm-dup-flag { color: var(--pw-crit, #b42318); }

/* Copy-yesterday: a real control, never a hint. Disabled states say why via
   the title, and stay legible rather than fading out of existence. */
.bm-copy-col { width: 1%; white-space: nowrap; }

.bm-copy {
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--pw-border, #e8e6e0);
  border-radius: var(--pw-radius-control, 12px);
  background: var(--pw-surface-sunken, #f7f6f3);
  color: var(--pw-text, #14140f);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.bm-copy:disabled {
  color: var(--pw-text-subtle, #6b6558);
  background: transparent;
  border-style: dashed;
  cursor: not-allowed;
}

@media (hover: hover) and (pointer: fine) {
  .bm-copy:not(:disabled):hover { background: var(--pw-surface, #fff); border-color: var(--pw-text-muted, #6b6862); }
}

.bm-copy:not(:disabled):active { transform: scale(.97); }

@media (prefers-reduced-motion: reduce) {
  .bm-copy:not(:disabled):active { transform: none; }
}

/* Row states. A copied row is marked so a person can see which values came
   from yesterday and still need a look before saving. */
.bm-table tbody tr.is-copied { background: var(--pw-info-soft, #eef4fb); }
.bm-table tbody tr.is-saved { background: var(--pw-ok-soft, #edf7ee); }
.bm-table tbody tr.is-failed { background: var(--pw-crit-soft, #fdecea); }

/* ----------------------------------------------------------------- footer */

.bm-footer {
  position: sticky;
  bottom: calc(var(--pw-shell-bottom-height, 0px) + 8px);
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border: 1px solid var(--pw-border, #e8e6e0);
  border-radius: var(--pw-radius-card, 16px);
  background: var(--pw-surface, #fff);
  box-shadow: var(--pw-shadow-2);
}

.bm-count {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.bm-footer .btn { min-height: 44px; }

/* The shell hides phone navigation while the software keyboard is open. */
html[data-pw-keyboard="open"] .bm-footer { bottom: 8px; }

/* ---------------------------------------------------------------- receipt */

.bm-receipt:empty { display: none; }

.bm-receipt__ok,
.bm-receipt__mixed {
  padding: 0.875rem 1rem;
  border: 1px solid var(--pw-border, #e8e6e0);
  border-left-width: 4px;
  border-radius: var(--pw-radius-control, 12px);
  font-size: 14px;
  line-height: 1.5;
}

.bm-receipt__ok { border-left-color: var(--pw-ok, #2f7d32); background: var(--pw-ok-soft, #edf7ee); }
.bm-receipt__mixed { border-left-color: var(--pw-crit, #b42318); background: var(--pw-crit-soft, #fdecea); }

.bm-receipt__list {
  margin: 0.5rem 0 0;
  padding-left: 1.125rem;
  display: grid;
  gap: 0.125rem;
}

.bm-receipt__list--fail { color: var(--pw-crit, #b42318); }

.bm-receipt__fail {
  margin: 0;
  padding: 0.875rem 1rem;
  border-radius: var(--pw-radius-control, 12px);
  background: var(--pw-crit-soft, #fdecea);
  color: var(--pw-crit, #b42318);
  font-size: 14px;
}

/* ------------------------------------------------------------------ phone */

/* Below 640px the table becomes stacked cards. A five-column grid on a 390px
   screen either scrolls sideways or shrinks the inputs under the touch floor,
   and neither is acceptable on the device most of this work happens on. */
@media (max-width: 640px) {
  .bm-table-wrap { border: 0; background: transparent; overflow-x: visible; }
  .bm-table, .bm-table tbody, .bm-table tr, .bm-table th, .bm-table td { display: block; }
  .bm-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

  .bm-table tbody tr {
    margin-bottom: 0.75rem;
    padding: 0.875rem 1rem;
    border: 1px solid var(--pw-border, #e8e6e0);
    border-radius: var(--pw-radius-card, 16px);
    background: var(--pw-surface, #fff);
  }

  .bm-table tbody th,
  .bm-table tbody td { padding: 0.25rem 0; border-bottom: 0; text-align: left; }

  .bm-table td.bm-num { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
  .bm-table td.bm-num::before {
    content: attr(data-label);
    font-size: 14px;
    color: var(--pw-text-muted, #6b6862);
  }
  .bm-input { width: 6rem; }
  .bm-copy-col { width: auto; }
  .bm-copy { width: 100%; margin-top: 0.375rem; }

  .bm-footer { flex-direction: column; align-items: stretch; }
  .bm-footer .btn { width: 100%; }
}

/* Old Android: color-mix() and the newer tokens are unsupported, so the row
   states and the sticky footer would lose their surfaces entirely. */
@supports not (color: color-mix(in srgb, red 50%, blue)) {
  .bm-table-wrap,
  .bm-footer { border: 1px solid #c7c7c2; background: #ffffff; }
  .bm-input { border: 1px solid #c7c7c2; background: #ffffff; color: #14140f; }
  .bm-copy { border: 1px solid #c7c7c2; background: #f1f1ef; color: #14140f; }
  .bm-table tbody tr.is-copied { background: #eef4fb; }
  .bm-table tbody tr.is-saved { background: #edf7ee; }
  .bm-table tbody tr.is-failed { background: #fdecea; }
  .bm-receipt__ok { background: #edf7ee; border-left-color: #2f7d32; }
  .bm-receipt__mixed { background: #fdecea; border-left-color: #b42318; }
}
