.finance-page { background: #f6f7fa; color: #1d2134; }
.finance-frame { width: min(100%, 1240px); margin-inline: auto; padding-inline: 32px; }
.finance-header { background: #fff; border-bottom: 1px solid var(--line); }
.finance-header-inner { display: flex; align-items: center; gap: 20px; min-height: 70px; }
.finance-home img { width: 44px; height: 44px; }
.finance-back { color: var(--muted); text-decoration: none; font-size: .9rem; font-weight: 650; }
.finance-back:hover { text-decoration: underline; }
.finance-signout { margin-left: auto; }
.finance-main { padding-block: 36px 48px; }
.finance-main h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); letter-spacing: -.055em; line-height: 1.1; }
.finance-heading { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; margin-bottom: 22px; }
.finance-heading p { color: var(--muted); font-size: .88rem; margin-top: 8px; }
.finance-heading-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.finance-button { border: 1px solid var(--line); border-radius: 9px; padding: 0 13px; min-height: 40px; background: white; color: #2a3149; font-size: .88rem; font-weight: 690; white-space: nowrap; }
.finance-button:hover { background: #f6f7fa; }
.finance-button:disabled { opacity: .65; cursor: wait; }
.finance-entry-link { display: inline-flex; align-items: center; text-decoration: none; }
.finance-primary { background: var(--brand-accent); border-color: var(--brand-accent); color: white; }
.finance-primary:hover { background: #c43b29; border-color: #c43b29; }
.finance-button:focus-visible, .finance-page :is(input, select, textarea, a):focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 2px; }
.finance-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.finance-total { display: grid; gap: 8px; padding: 16px; min-width: 0; }
.finance-total span { color: var(--muted); font-size: .83rem; font-weight: 620; }
.finance-total strong { font-size: clamp(1.15rem, 2.4vw, 1.75rem); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; letter-spacing: -.04em; }
.finance-net { background: var(--brand-tint); border-color: #f3d5d0; }
.finance-net span { color: var(--brand-ink); }
.finance-cash { margin-bottom: 18px; }
.finance-cash h2 { color: var(--muted); font-size: .84rem; font-weight: 650; margin: 0 0 8px; }
.finance-cash-values { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.finance-cash-values p { display: flex; flex-wrap: wrap; justify-content: space-between; column-gap: 8px; padding: 10px 12px; font-size: .84rem; }
.finance-cash-values strong { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.finance-register { overflow: hidden; }
.finance-register-head { display: flex; align-items: flex-end; flex-wrap: wrap; justify-content: space-between; gap: 12px 22px; padding: 16px; }
.finance-register h2, .finance-dialog h2 { font-size: 1.22rem; letter-spacing: -.025em; align-self: center; }
.finance-filters { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 8px; }
.finance-page label { display: grid; gap: 5px; color: #46516c; font-size: .76rem; font-weight: 650; min-width: 0; }
.finance-page :is(input, select, textarea) { font: inherit; color: #222941; font-size: .88rem; font-weight: 520; background: #fff; border: 1px solid #dce1ec; border-radius: 8px; padding: 8px 9px; min-width: 0; min-height: 40px; }
.finance-table-scroll { overflow-x: auto; }
.finance-table { width: 100%; min-width: 740px; border-collapse: collapse; font-size: .875rem; }
.finance-table :is(th, td) { padding: 12px 16px; text-align: left; border-block-start: 1px solid var(--line); }
.finance-table th { background: #f8f9fc; color: var(--muted); font-weight: 670; }
.finance-table td { vertical-align: top; }
.finance-table td:nth-child(4) { width: 100%; overflow-wrap: anywhere; }
.finance-table :is(th, td):nth-last-child(-n + 3) { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.finance-table td:first-child, .finance-table th:nth-child(2) { white-space: nowrap; }
.finance-table .finance-inflow { color: #196e4c; }
.finance-empty { padding: 24px 16px; color: var(--muted); font-size: .88rem; text-align: center; }
.finance-error { color: #9c372d; font-size: .85rem; line-height: 1.4; }
.finance-login { width: min(100%, 375px); padding: 24px; margin: 36px auto 0; }
.finance-login > .finance-primary { width: 100%; margin-block: 16px; }
.finance-login details { margin-top: 12px; }
.finance-login summary { cursor: pointer; }
#finance-telegram-wait p { line-height: 1.5; }
#finance-telegram-number { font-variant-numeric: tabular-nums; white-space: nowrap; }
.finance-login form { display: grid; gap: 12px; margin-top: 20px; }
.finance-login input { width: 100%; }
.finance-dialog { width: min(100% - 28px, 460px); color: #1d2134; border: 1px solid var(--line); border-radius: 14px; padding: 20px; box-shadow: 0 20px 70px #1617323b; }
.finance-dialog::backdrop { background: #20244178; }
.finance-dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 15px; }
.finance-close { width: 40px; padding: 0; font-size: 1.4rem; }
.finance-entry-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.finance-description { grid-column: 1 / -1; }
.finance-description textarea { resize: vertical; }
.finance-dialog .finance-primary { display: block; margin: 18px 0 0 auto; }
.finance-dialog .finance-error { margin-top: 10px; }
.contacts-filters input { flex: 1 1 210px; }
.contacts-table :is(th, td):nth-child(n) { text-align: left; white-space: normal; width: auto; }
.contacts-table td:nth-child(5) { width: 100%; }
.contacts-table td:last-child { text-align: right; }
.contact-name { font-weight: 700; }
.teachers-table { min-width: 0; }
.teachers-table :is(th, td):nth-child(n) { text-align: left; white-space: normal; overflow-wrap: anywhere; }
.teachers-table th, .teachers-table td { padding-inline: clamp(8px, 2vw, 16px); }
.teacher-link-status { color: var(--muted); }
.teacher-link-status.is-linked { color: #196e4c; }
.contact-roles { display: flex; flex-wrap: wrap; gap: 5px 14px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px 10px; margin: 14px 0; }
.contact-roles legend { color: var(--muted); font-size: .78rem; }
.contact-roles label { display: flex; align-items: center; color: inherit; font-size: .88rem; }
.contact-roles input { margin: 0; min-height: 0; }
.contact-teacher-field { display: block; margin-bottom: 14px; }

@media (max-width: 650px) {
  .finance-frame { padding-inline: 14px; }
  .finance-header-inner { min-height: 60px; gap: 12px; }
  .finance-main { padding-top: 22px; }
  .finance-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .finance-total { padding: 10px 8px; }
  .finance-total span { font-size: .73rem; }
  .finance-register-head { align-items: flex-start; padding: 12px; }
  .finance-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .finance-filters :is(input, select) { width: 100%; }
  .finance-filters .finance-button { grid-column: 1 / -1; }
}
