/* Expenses cards (see expenses.js). Colors come from the theme variables defined in
   index.html; every element has an exp- class so the module can be restyled from here. */
.exp-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; margin-bottom: 14px; color-scheme: light; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .exp-card { color-scheme: dark; }
}
.exp-card [hidden] { display: none; }
.exp-card h2 { margin-bottom: 12px; }
.exp-card :is(h3, h4) { margin: 0; }
.exp-card :is(select, input, button):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Form */
.exp-form { display: grid; gap: 12px; margin: 0; }
.exp-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 12px; }
.exp-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.exp-field label { font-size: 0.8rem; color: var(--muted); }
.exp-field :is(select, input) {
  width: 100%; min-width: 0; max-width: 100%; min-height: 42px; padding: 8px 10px;
  font: inherit; font-size: 16px; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; }
/* Without this iOS Safari sizes the date field from its native widget and overflows narrow cards. */
.exp-field input[type="date"] { -webkit-appearance: none; appearance: none; text-align: left; }
.exp-field [aria-invalid="true"] { border-color: var(--loss); }
.exp-field-error, .exp-form-error, .exp-recap-error { margin: 0; font-size: 0.82rem; color: var(--loss); }
.exp-field-error:empty, .exp-form-error:empty, .exp-recap-error:empty { display: none; }

.exp-warning { margin: 0; padding: 8px 10px; font-size: 0.85rem; color: var(--loss);
  background: var(--bg); border: 1px solid var(--loss); border-radius: 8px; }
.exp-warning:empty { display: none; }

.exp-submit { width: 100%; min-height: 44px; font-size: 1rem; font-weight: 600;
  background: var(--accent); color: var(--bg); }
.exp-submit-confirm { background: var(--loss); }

.exp-confirmation { margin: 0; padding: 8px 10px; font-size: 0.85rem; line-height: 1.4;
  color: var(--text); background: var(--accent-soft); border-radius: 8px; overflow-wrap: anywhere; }
.exp-confirmation:empty { display: none; }

/* Recap */
.exp-periods { display: flex; gap: 6px; margin-bottom: 14px; }
.exp-period { flex: 1; min-width: 0; min-height: 40px; padding: 6px 2px; font-size: 0.8rem; font-weight: 600;
  background: var(--done-bg); color: var(--text); }
.exp-period[aria-pressed="true"] { background: var(--accent); color: var(--bg); }

.exp-total { padding: 4px 0 2px; text-align: center; }
.exp-total:focus { outline: none; }
.exp-total-label { margin: 0; font-size: 0.78rem; color: var(--muted); }
.exp-total-amount { margin: 2px 0; font-size: 2rem; font-weight: 800; line-height: 1.15;
  color: var(--positive); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.exp-total-amount.exp-total-negative { color: var(--loss); }
.exp-total-amount.exp-total-zero { color: var(--muted); }

.exp-kind-row { display: flex; gap: 6px; margin-bottom: 14px; }
.exp-kind { flex: 1; min-height: 40px; padding: 6px 2px; font-size: 0.85rem; font-weight: 600;
  background: var(--done-bg); color: var(--text); }
.exp-kind[aria-pressed="true"] { background: var(--accent); color: var(--bg); }
.exp-total-count { margin: 0; font-size: 0.8rem; color: var(--muted); }
.exp-recap-error { margin-top: 8px; text-align: center; }

.exp-section { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.exp-section:empty { display: none; }
.exp-section-title { margin-bottom: 10px; font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }

.exp-accounts { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.exp-account-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 0.88rem; }
.exp-account-name { min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.exp-account-amount { flex: none; font-weight: 700; color: var(--loss); font-variant-numeric: tabular-nums; }
.exp-bar { height: 6px; margin-top: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.exp-bar-fill { display: block; height: 100%; min-width: 4px; border-radius: 3px; background: var(--loss); }

.exp-day + .exp-day { margin-top: 14px; }
.exp-day-title { margin-bottom: 2px; font-size: 0.85rem; font-weight: 700; }
.exp-list { margin: 0; padding: 0; list-style: none; }
.exp-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center;
  column-gap: 8px; padding: 8px 6px; margin: 0 -6px; border-top: 1px solid var(--border);
  border-radius: 8px; cursor: pointer; transition: background-color .15s ease; }
.exp-row:first-child { border-top: none; }
.exp-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
@media (hover: hover) { .exp-row:hover { background: var(--done-bg); } }
.exp-row-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.exp-row-label { font-size: 0.9rem; font-weight: 600; overflow-wrap: anywhere; }
.exp-row-account { font-size: 0.76rem; color: var(--muted); overflow-wrap: anywhere; }
.exp-row-amount { font-size: 0.9rem; font-weight: 700; color: var(--loss);
  white-space: nowrap; font-variant-numeric: tabular-nums; }
.exp-row-income .exp-row-amount { color: var(--positive); }
.exp-row-transfer .exp-row-amount { color: var(--accent); }
.exp-row-menu { position: fixed; z-index: 50; min-width: 170px; max-width: 240px; padding: 6px; background: var(--card);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 28px rgba(0, 0, 0, .3); }
.exp-row-menu-del { width: 100%; min-height: 42px; padding: 8px 12px; font-size: 0.9rem; font-weight: 600;
  color: var(--loss); background: none; text-align: left; border-radius: 8px; }
@media (hover: hover) { .exp-row-menu-del:hover { background: var(--done-bg); } }
.exp-row-menu-question { margin: 4px 6px 10px; font-size: 0.82rem; color: var(--text); line-height: 1.35; }
.exp-row-menu-actions { display: flex; gap: 6px; }
.exp-row-menu-cancel, .exp-row-menu-confirm { flex: 1; min-width: 0; min-height: 40px; padding: 8px 6px;
  font-size: 0.85rem; font-weight: 600; border-radius: 8px; }
.exp-row-menu-cancel { background: var(--done-bg); color: var(--text); }
.exp-row-menu-confirm { background: var(--loss); color: #fff; }

.exp-empty { margin: 0; padding: 12px 0 4px; text-align: center; font-size: 0.88rem; color: var(--muted); }
