.expense-page { --sheet-width: 1280px; }
.expense-hero { padding: 1rem max(1.25rem, calc((100% - var(--sheet-width))/2 + 1.25rem)) 2rem; background: linear-gradient(135deg, #edf9f8, #e4f1f6); border-bottom: 1px solid var(--line); }
.expense-hero__bar { display: flex; justify-content: space-between; gap: 1rem; font-size: .85rem; }
.back-link { color: var(--blue); font-weight: 700; text-underline-offset: .2em; }
.expense-logo { display: block; width: min(280px, 100%); height: auto; margin: 1.5rem 0 1rem; padding: .45rem .65rem; background: #fff; border-radius: 10px; }
.expense-hero h1 { margin: .15rem 0 .65rem; font-size: clamp(1.65rem, 4vw, 2.75rem); line-height: 1.4; letter-spacing: .02em; }
.expense-hero p:last-child { max-width: 48rem; margin: 0; }
.expense-main { max-width: var(--sheet-width); min-width: 0; margin: 1.5rem auto 4rem; padding: 0 1.25rem; }
.expense-main > section { min-width: 0; margin-top: 1.25rem; padding: clamp(1rem, 2.5vw, 1.75rem); border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: 0 8px 24px #0c294009; }
.expense-main h2 { margin: .1rem 0 .45rem; font-family: inherit; font-size: 1.2rem; }
.expense-main .eyebrow { color: #93611b; }
.expense-main .expense-intro { padding-block: .65rem; border-left: 4px solid var(--teal); box-shadow: none; }
.expense-intro p { margin: .2rem 0; font-size: .9rem; }
.rule-panel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
.rule-fields { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.5rem; }
.rule-fields label { min-width: 0; font-weight: 700; }
.attribute-fields { display: contents; }
.attribute-fields small { display: block; margin-top: .3rem; font-size: .8rem; font-weight: 400; color: #4d626a; }
.expense-page input, .expense-page select { display: block; width: 100%; min-width: 0; min-height: 2.75rem; padding: .55rem .65rem; border: 1px solid #82989e; border-radius: 8px; background: #fff; color: var(--ink); font: inherit; }
.rule-fields input, .rule-fields select { margin-top: .35rem; }
.expense-page select:focus-visible, .table-scroll:focus-visible { outline: 3px solid var(--sun); outline-offset: 3px; }
.expense-page [aria-invalid="true"] { border: 2px solid var(--danger); background: #fff6f6; }
.expense-page button { min-height: 2.5rem; border-radius: 8px; padding: .5rem .8rem; cursor: pointer; font-size: .87rem; touch-action: manipulation; }
.expense-page button:disabled { cursor: default; opacity: .55; }
.save-status { margin: 0; text-align: right; color: var(--teal); font-size: .8rem; overflow-wrap: anywhere; }
.save-status[data-problem="true"] { color: var(--danger); font-weight: 700; }
.rule-notice, .validation { grid-column: 1 / -1; margin: 0; padding: .65rem .85rem; font-size: .88rem; }
.rule-notice { border-radius: 8px; color: #174c63; background: var(--blue-soft); }
.validation { margin-block: 1rem; background: #fff3cd; border-left: 4px solid var(--sun); color: #513b00; }
.rule-notice:empty, .validation:empty { display: none; }
.rule-meta { grid-column: 1 / -1; margin: 0; color: #4d626a; font-size: .78rem; }
.rule-meta a { color: var(--blue); text-underline-offset: .2em; }
.sheet-heading { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; }
.table-hint { margin: .65rem 0 0; font-size: .8rem; color: #4d626a; }
.table-scroll { position: relative; width: 100%; max-width: 100%; min-width: 0; overflow-x: auto; overscroll-behavior-x: contain; margin: .5rem 0 1rem; }
.table-scroll table { width: 100%; min-width: 1100px; border-collapse: collapse; table-layout: fixed; }
.table-scroll th { padding: .7rem .5rem; background: #f0f5f6; color: #31525d; font-size: .8rem; font-weight: 700; border-bottom: 2px solid var(--line); text-align: left; }
.table-scroll td { padding: .85rem .5rem; vertical-align: top; border-bottom: 1px solid var(--line); font-size: .87rem; }
.table-scroll th:nth-child(1) { width: 21%; }
.table-scroll th:nth-child(2) { width: 27%; }
.table-scroll th:nth-child(3) { width: 15%; text-align: right; }
.table-scroll th:nth-child(4) { width: 13%; text-align: right; }
.table-scroll th:nth-child(5) { width: 18%; text-align: right; }
.table-scroll th:nth-child(6) { width: 6%; }
.official-note { margin: 0 0 .5rem; color: #3a555f; font-size: .8rem; line-height: 1.6; overflow-wrap: anywhere; }
.amount-input { text-align: right; font-variant-numeric: tabular-nums; }
.row-rate, .row-grant { display: block; padding: .6rem 0; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.row-grant { font-weight: 700; }
.expense-page .remove-row { min-width: 2.5rem; padding: .5rem .15rem; border: 0; background: transparent; color: var(--danger); white-space: nowrap; }
.expense-main .summary-card { background: #083d5f; color: #fff; }
.summary-card .eyebrow { color: #ffca6a; }
.summary-card dl { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin: 1rem 0 0; }
.summary-card dl > div { min-width: 0; border-top: 1px solid #ffffff55; padding: .8rem 0; }
.summary-card dt { font-size: .78rem; color: #e0edf3; }
.summary-card dd { margin: .4rem 0 0; font-size: clamp(1rem, 1.7vw, 1.45rem); line-height: 1.5; font-weight: 800; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.calc-notes { margin: .7rem 0 0; font-size: .8rem; }
.calc-notes p { margin: .4rem 0; }
.local-card p { margin: .4rem 0 1rem; font-size: .9rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@media (max-width: 760px) {
  .expense-hero__bar { flex-wrap: wrap; }
  .rule-panel { display: block; }
  .rule-fields { display: block; }
  .rule-fields label { display: block; margin-top: 1rem; }
  .save-status { text-align: left; margin: .6rem 0; }
  .rule-notice { margin-top: 1rem; }
  .rule-meta { margin-top: .65rem; }
  .summary-card dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 420px) {
  .expense-hero { padding-inline: .9rem; }
  .expense-hero__bar span { display: none; }
  .expense-main { padding-inline: .65rem; }
  .expense-main > section { padding: 1rem; border-radius: 12px; }
  .summary-card dl { grid-template-columns: 1fr; gap: .3rem; }
}
