/* Finance — period money screens. Tokens stay in main.css. */

.hub-main:has(#finance-panel:not([hidden])) {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.hub-main:has(#finance-panel:not([hidden])) > .subnav {
  flex: 0 0 auto;
}

.hub-main:has(#finance-panel:not([hidden])) > .stage {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

#finance-panel:not([hidden]) {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.fin-screen {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  gap: 10px;
  overflow: hidden;
}

.fin-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

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

.fin-periods .btn-ghost.is-selected {
  border-color: var(--brand);
  color: var(--brand);
  font-weight: 600;
}

.fin-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 16px;
}

.fin-wide {
  width: 100%;
}

.fin-table-wrap {
  overflow: auto;
  max-height: 360px;
}

.fin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
}

.fin-table th,
.fin-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

.fin-table thead th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.fin-table td:last-child,
.fin-table th:last-child {
  text-align: right;
  white-space: nowrap;
}

.fin-pl th {
  font-weight: 500;
  color: var(--ink);
  width: 60%;
}

.fin-note {
  margin: 8px 0 0;
}


/* Invoices — TABLES desk (reuses ord-po-* from ordering.css) */
.fin-inv-screen {
  min-height: 0;
}

#finance-panel .ord-po-workspace {
  flex: 1 1 auto;
  min-height: 0;
  height: calc(100vh - 220px);
  max-height: none;
}

/* Match Purchase Orders: list | gutter | detail. Drag width is applied in JS. */
#finance-panel .ord-po-layout.is-split {
  grid-template-columns: minmax(200px, 420px) var(--split-gutter) minmax(280px, 1fr);
}

#finance-panel .ord-po-list {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--surface);
}

#finance-panel .ord-po-row .ord-po-col:has(.ord-pill) {
  display: flex;
  justify-content: center;
  align-items: center;
}

#finance-panel .ord-po-row .ord-pill {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fin-inv-detail {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  padding: 4px 2px 12px;
}

.fin-inv-detail-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.fin-inv-title {
  margin: 0;
  color: var(--brand);
  font-size: 1.15rem;
  font-weight: 700;
}

.fin-inv-fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px 16px;
}

.fin-inv-fields .field,
.fin-inv-note.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fin-inv-fields input,
.fin-inv-note textarea,
.fin-qty {
  height: 34px;
  font-size: 0.92rem;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 0 8px;
}

.fin-inv-note textarea {
  height: auto;
  padding: 8px;
}

.fin-inv-total {
  color: var(--brand);
  font-size: 1.05rem;
}

.fin-qty {
  width: 88px;
}

.fin-inv-match-wrap {
  max-height: none;
  flex: 1 1 auto;
  min-height: 0;
}

.fin-match-table th,
.fin-match-table td {
  text-align: center;
  white-space: nowrap;
}

.fin-match-table th:first-child,
.fin-match-table td:first-child {
  text-align: left;
  white-space: normal;
}

.fin-match-product {
  max-width: 220px;
}

.fin-match-product strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fin-inv-pick-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fin-inv-pick-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 8px 10px;
  cursor: pointer;
}

.fin-inv-pick-row:hover {
  border-color: var(--brand);
}

.fin-inv-detail-foot {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

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