/* Erweiterung 3 (Agent C): expenses area - month overview, recurring expenses, planning value.
   Builds on app.css variables (--c-*, --tap, --radius) and its base classes (.card, .cards, .btn, .badge, .alert,
   .action-cards). Desktop: due dates as a table; smartphone (<= 600px): cards instead of the table. */

.rex-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; }

/* ---------- jump bar and month navigation */
.rex-jump { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1rem; }
.rex-monthnav { align-items: center; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); padding: .5rem .75rem; }
.rex-month-label { font-weight: 700; font-size: 1.1rem; min-width: 9.5rem; text-align: center; }
.rex-monthnav .field input { min-height: var(--tap); }
.rex-sec { scroll-margin-top: calc(var(--nav-h) + .5rem); }

/* ---------- totals per currency */
.rex-totals-wrap h3, .rex-month h3, .rex-planning h3 { font-size: 1.05rem; margin: 1rem 0 .5rem; }
.rex-totals { list-style: none; padding: 0; margin: 0; display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); }
.rex-total { border: 1px solid var(--c-border); border-radius: var(--radius); padding: .5rem .75rem; background: var(--c-surface); }
.rex-total-incomplete { border-color: #e3c97a; background: var(--c-warn-bg); }
.rex-cur { display: inline-block; font-weight: 700; letter-spacing: .05em; margin-bottom: .25rem; }
.rex-total dl { margin: 0; display: grid; gap: .15rem; }
.rex-total dl > div { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.rex-total dt { color: var(--c-muted); }
.rex-total dd { margin: 0; font-weight: 600; text-align: right; }

/* ---------- due dates: table (desktop) */
.rex-paidnote { margin: .25rem 0 .5rem; padding: .4rem .75rem; border-left: 4px solid var(--c-primary); background: var(--c-info-bg); border-radius: 0 var(--radius) var(--radius) 0; }
.rex-table-wrap { overflow-x: auto; }
.rex-table { width: 100%; border-collapse: collapse; }
.rex-table th, .rex-table td { text-align: left; vertical-align: top; padding: .5rem .5rem; border-bottom: 1px solid var(--c-subtle); }
.rex-table thead th { font-size: .9rem; color: var(--c-muted); border-bottom: 2px solid var(--c-border); }
.rex-table tbody th { font-weight: 400; }
.rex-table td:first-child, .rex-table thead th { white-space: nowrap; }
.rex-table td:last-child { white-space: nowrap; width: 1%; }
.rex-switch label { white-space: nowrap; }
.rex-title { font-weight: 700; }
.rex-amount { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 600; }
.rex-unknown { font-style: italic; color: var(--c-warn); }
.rex-not-counted .rex-amount { color: var(--c-muted); text-decoration: line-through dotted; }
.rex-not-counted .rex-amount.rex-unknown { text-decoration: none; }
.rex-is-paid { background: var(--c-ok-bg); }
.rex-snap { display: block; font-size: .85rem; font-weight: 400; white-space: normal; }

/* paid switch: large touch target, visible focus */
.rex-switch { display: inline-flex; align-items: center; gap: .5rem; min-height: var(--tap); }
.rex-switch input { appearance: none; -webkit-appearance: none; width: 3rem; height: 1.6rem; border-radius: 999px; border: 2px solid var(--c-border);
  background: var(--c-subtle); position: relative; cursor: pointer; margin: 0; flex: none; }
.rex-switch input::before { content: ""; position: absolute; top: 2px; left: 2px; width: calc(1.6rem - 8px); height: calc(1.6rem - 8px); border-radius: 50%;
  background: var(--c-muted); transition: transform .15s ease; }
.rex-switch input:checked { background: var(--c-ok-bg); border-color: var(--c-ok); }
.rex-switch input:checked::before { transform: translateX(1.4rem); background: var(--c-ok); }
.rex-switch input:focus-visible { outline: 3px solid var(--c-focus); outline-offset: 3px; }
.rex-switch input:disabled { opacity: .6; cursor: progress; }
.rex-switch label { cursor: pointer; min-height: var(--tap); display: inline-flex; align-items: center; }
/* the whole 44px row reacts to the pointer */
.rex-switch { padding: 0 .25rem; }

/* ---------- due dates: cards (smartphone) */
.rex-cards { list-style: none; padding: 0; margin: 0; display: none; gap: .5rem; }
.rex-card { border: 1px solid var(--c-border); border-radius: var(--radius); padding: .75rem; background: var(--c-surface); }
.rex-card.rex-is-paid { background: var(--c-ok-bg); }
.rex-card-head { display: flex; justify-content: space-between; gap: .75rem; align-items: baseline; }
.rex-card p { margin: .2rem 0; }
.rex-card-foot { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; margin-top: .25rem; }

/* ---------- planning value: visibly separate */
.rex-planning { margin-top: 1.25rem; border: 2px dashed var(--c-border); border-radius: var(--radius); padding: .5rem 1rem 1rem; background: var(--c-bg); }
.rex-planning h3 { margin-top: .5rem; }
.rex-plan-sums { list-style: none; padding: 0; margin: .25rem 0 .5rem; }
.rex-plan-sums li { min-height: 1.75rem; }

/* ---------- reminders, pauses */
.rex-reminders { margin-top: 1rem; }
.rex-reminders h3 { margin-top: 0; }
.rex-reminders ul { margin: 0; padding-left: 1.25rem; }
.rex-paused { margin-top: .75rem; }

/* ---------- series */
.rex-tpl-title { font-size: 1.05rem; margin: 0 0 .25rem; }
.rex-templates .action-card { min-height: calc(var(--tap) + .5rem); }
.rex-series { margin-top: 1rem; }
.rex-series-card h3 { margin: 0 0 .25rem; }
.rex-series-card p { margin: .2rem 0; }
.rex-person-row { display: flex; align-items: center; gap: .25rem; min-height: 2rem; flex-wrap: wrap; }
.rex-pauses ul { margin: 0; }
.rex-pauses li { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.rex-row { display: flex; gap: .75rem; flex-wrap: wrap; }
.rex-row > .field { flex: 1 1 12rem; }

/* ---------- smartphone: cards instead of the table, 44px touch targets */
@media (max-width: 600px) {
  .rex-table-wrap { display: none; }
  .rex-cards { display: grid; }
  .rex-monthnav { gap: .5rem; }
  .rex-monthnav .rex-month-label { order: -1; width: 100%; text-align: left; }
  .rex-jump .btn, .rex-monthnav .btn, .rex-series-card .actions .btn, .rex-pauses .btn { min-height: var(--tap); }
  .rex-series-card .actions { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
  .rex-series-card .actions .btn { width: 100%; }
  .rex-total dl > div { justify-content: space-between; }
}
