/* Finance pages (ARCHITECTURE 9.1). Linked in the staff head (AddStaffStylesheet, CR-sales-001); every selector carries the
   fin- prefix. Layout rule 15: no horizontal page scroll at 390 px and 1366 px; wide tables scroll inside their own box, and
   lists stack into cards below 600 px. Touch targets >= 44 px. */

.fin-page { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.fin-page > * { min-width: 0; }

.fin-header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 8px 16px; }
.fin-header__title { min-width: 0; flex: 1 1 260px; }
.fin-header__subtitle { margin: 4px 0 0; color: #555555; overflow-wrap: anywhere; }
.fin-header__actions { display: flex; flex-wrap: wrap; gap: 8px; }

.fin-links { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: -8px; }
.fin-links__link { display: inline-flex; align-items: center; min-height: 32px; color: #3B5E26; font-weight: 600; text-decoration: none; }
.fin-links__link:hover { text-decoration: underline; }

.fin-section { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.fin-section__title { margin: 0; font-size: 1.1rem; font-weight: 700; }
.fin-muted { color: #616161; }
.fin-small { font-size: 0.85rem; }
.fin-wrap { overflow-wrap: anywhere; }

.fin-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px; }
.fin-toolbar > .fin-field { flex: 1 1 160px; }

.fin-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 12px 16px; align-items: end; }
.fin-form__full { grid-column: 1 / -1; }
.fin-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fin-field label, .fin-label { font-size: 0.85rem; font-weight: 600; color: #424242; }
.fin-field select.ic-input { appearance: auto; }
.fin-field textarea.ic-input { height: 88px; padding-top: 8px; }
.fin-check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; }
.fin-check input { width: 20px; height: 20px; }
.fin-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.fin-figures { display: flex; flex-wrap: wrap; gap: 12px; }
.fin-figure { flex: 1 1 140px; padding: 12px; border: 1px solid #DADADA; border-radius: 8px; background: #FFFFFF; }
.fin-figure__value { font-size: 1.5rem; font-weight: 700; }
.fin-figure__label { font-size: 0.85rem; color: #616161; }
.fin-figure--warning { border-color: #E0A100; background: #FFF8E1; }

.fin-table-wrap { width: 100%; max-width: 100%; overflow-x: auto; border: 1px solid #E0E0E0; border-radius: 8px; background: #FFFFFF; }
.fin-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.fin-table th, .fin-table td { padding: 8px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid #EEEEEE; }
.fin-table th { font-size: 0.8rem; font-weight: 700; color: #424242; background: #F7F7F4; white-space: nowrap; }
.fin-table td.fin-num, .fin-table th.fin-num { text-align: right; white-space: nowrap; }
.fin-table tr:last-child td { border-bottom: 0; }
.fin-table a { color: #3B5E26; font-weight: 600; }
.fin-table .ic-input { height: 40px; }
.fin-table tr.fin-row--void td { color: #8A8A8A; text-decoration: line-through; }
.fin-table tr.fin-row--void td.fin-plain { text-decoration: none; }

@media (max-width: 599.98px) {
  .fin-table--stack thead { display: none; }
  .fin-table--stack, .fin-table--stack tbody, .fin-table--stack tr, .fin-table--stack td { display: block; width: 100%; box-sizing: border-box; }
  .fin-table--stack tr { padding: 8px 0; border-bottom: 1px solid #E0E0E0; }
  .fin-table--stack tr:last-child { border-bottom: 0; }
  .fin-table--stack td { display: flex; justify-content: space-between; gap: 12px; padding: 4px 12px; border: 0; text-align: right; }
  .fin-table--stack td::before { content: attr(data-label); flex: 0 0 auto; font-weight: 600; color: #616161; text-align: left; }
  .fin-table--stack td:not([data-label])::before, .fin-table--stack td[data-label=""]::before { content: none; }
  .fin-table--stack td:not([data-label]) { justify-content: flex-start; text-align: left; }
}

.fin-chip { display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; border-radius: 12px; font-size: 0.8rem; font-weight: 700;
  background: #ECEFF1; color: #263238; white-space: nowrap; }
.fin-chip--ok { background: #E8F5E9; color: #1B5E20; }
.fin-chip--info { background: #E3F2FD; color: #0D47A1; }
.fin-chip--warning { background: #FFF3E0; color: #8A4B00; }
.fin-chip--critical { background: #FDECEA; color: #8C1D18; }

.fin-card { padding: 12px; border: 1px solid #DADADA; border-radius: 8px; background: #FFFFFF; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.fin-card__title { margin: 0; font-size: 1rem; font-weight: 700; }

.fin-bar { height: 8px; border-radius: 4px; background: #EEEEEE; overflow: hidden; min-width: 60px; }
.fin-bar__fill { height: 100%; background: #538135; }
