/**
 * FENN Details — Transaction Review & Categorization v1.
 * Warm retail household activity surface (not an accounting ledger).
 */

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1100px 520px at 8% -12%, #e7efe9 0%, transparent 55%),
    radial-gradient(900px 480px at 100% 0%, #f0e8dc 0%, transparent 52%),
    linear-gradient(180deg, #f7f4ee 0%, var(--bg) 42%, #efebe3 100%);
  color: var(--text);
  font-family: var(--sans);
}

.shell {
  max-width: 920px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 5.5rem;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.brand {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.subtitle {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.15rem;
}

.controls {
  display: flex;
  gap: 0.65rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.ghost {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.55rem 0.35rem;
  border-bottom: 1px solid transparent;
}

.ghost:hover {
  color: var(--text);
}

.ghost[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.hero {
  padding: 1.5rem 0 0.75rem;
}

.hero h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3vw, 2.05rem);
  font-weight: 650;
  letter-spacing: -0.02em;
}

.meta {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.45;
}

.read-only-note {
  margin: 0.75rem 0 0;
  padding: 0.75rem 0.9rem;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.4;
}

.view-toggle {
  display: flex;
  gap: 0.5rem;
  margin: 0.5rem 0 1rem;
  flex-wrap: wrap;
}

.view-btn {
  min-height: 44px;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.view-btn[aria-pressed="true"] {
  background: var(--text);
  color: var(--btn-fg);
  border-color: var(--text);
}

.activity-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.55rem 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.activity-link:hover {
  background: var(--bg-soft);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  margin-bottom: 1rem;
  padding: 0.9rem 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 8.5rem;
}

.field.grow {
  flex: 1 1 12rem;
}

.field span {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
}

.field input,
.field select {
  min-height: 44px;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--text);
  font: inherit;
}

.btn-secondary {
  min-height: 44px;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary:hover {
  background: var(--bg-soft);
}

.toast {
  margin: 0 0 0.85rem;
  padding: 0.75rem 0.95rem;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 600;
}

.page-status {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.4;
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  margin: 1rem 0 0.5rem;
}

.load-more-wrap .btn-secondary {
  min-width: min(100%, 16rem);
}

.empty {
  padding: 1.75rem 1.25rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.empty h2 {
  margin: 0 0 0.45rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
}

.empty p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.tx-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tx-row {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.95rem 1rem;
  box-shadow: var(--shadow);
}

.tx-main {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem 1rem;
  align-items: start;
}

.tx-merchant {
  margin: 0;
  font-weight: 700;
  font-size: 1.02rem;
}

.tx-meta {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.tx-amount {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 1.02rem;
  white-space: nowrap;
}

.tx-category {
  margin: 0.55rem 0 0;
  font-size: 0.92rem;
}

.tx-reason {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.tx-suggestion {
  margin: 0.35rem 0 0;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
}

.tx-actions {
  margin-top: 0.85rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}

.tx-actions select {
  min-height: 44px;
  min-width: min(100%, 14rem);
  flex: 1 1 12rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--text);
  font: inherit;
}

.tx-actions button {
  min-height: 44px;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--btn-bg);
  color: var(--btn-fg);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.tx-actions button:hover {
  background: var(--btn-bg-hover);
}

.tx-actions button:disabled,
.tx-actions select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.tx-actions button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.tx-detail {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.merchant-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.merchant-row {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.05rem;
  box-shadow: var(--shadow);
}

.merchant-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem 1rem;
  align-items: start;
}

.merchant-name {
  margin: 0;
  font-weight: 700;
  font-size: 1.08rem;
}

.merchant-meta {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.merchant-hint {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.merchant-suggestion {
  margin: 0.45rem 0 0;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.4;
}

.merchant-total {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 1.05rem;
  white-space: nowrap;
}

.merchant-preview {
  margin: 0.85rem 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.merchant-preview li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.merchant-preview .pv-amount {
  font-family: var(--mono);
  color: var(--text);
  white-space: nowrap;
}

.merchant-actions {
  margin-top: 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.merchant-actions .row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}

.merchant-actions select {
  min-height: 44px;
  min-width: min(100%, 14rem);
  flex: 1 1 12rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--text);
  font: inherit;
}

.merchant-actions button {
  min-height: 44px;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--btn-bg);
  color: var(--btn-fg);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.merchant-actions button:hover {
  background: var(--btn-bg-hover);
}

.merchant-actions button:disabled,
.merchant-actions select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.merchant-actions button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.confirm-box {
  margin-top: 0.25rem;
  padding: 0.85rem 0.95rem;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
}

.confirm-box p {
  margin: 0 0 0.75rem;
  font-weight: 600;
  line-height: 1.4;
}

.remember-row {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  margin: 0 0 0.85rem;
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.4;
}

.remember-row input {
  margin-top: 0.2rem;
  width: 1.1rem;
  height: 1.1rem;
}

.remember-hint {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
}

@media (max-width: 720px) {
  .shell {
    padding: 1rem 1rem 5.75rem;
  }

  .top {
    flex-direction: column;
    align-items: flex-start;
  }

  .controls {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 0.15rem;
  }

  .tx-main,
  .merchant-head {
    grid-template-columns: 1fr;
  }

  .tx-amount,
  .merchant-total {
    justify-self: start;
  }

  .filters {
    padding: 0.85rem;
  }

  .field {
    flex: 1 1 100%;
  }
}

/* Compact activity list: scan the essentials first; expand for context or changes. */
.activity-link {
  margin-left: auto;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 18px color-mix(in srgb, var(--accent) 24%, transparent);
}

.activity-link:hover {
  background: color-mix(in srgb, var(--accent) 86%, #000);
}

.tx-list { gap: 0.45rem; }

.tx-row {
  padding: 0;
  overflow: hidden;
  box-shadow: 0 8px 22px rgba(28, 25, 21, 0.055);
}

.tx-row.is-expanded { border-color: var(--accent); }

.tx-summary {
  width: 100%;
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr) minmax(5.5rem, 0.75fr) auto auto auto;
  align-items: center;
  gap: 0.6rem;
  min-height: 3.5rem;
  padding: 0.65rem 0.85rem;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.tx-summary:hover { background: var(--bg-soft); }
.tx-summary:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }
.tx-date, .tx-account { color: var(--muted); font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-summary .tx-merchant { font-size: 0.94rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-summary .tx-amount { font-size: 0.94rem; }
.tx-category-pill { padding: 0.22rem 0.45rem; border-radius: 999px; background: color-mix(in srgb, var(--watch) 15%, transparent); color: var(--watch); font-size: 0.72rem; font-weight: 700; white-space: nowrap; }
.tx-chevron { color: var(--accent); font-size: 1.1rem; line-height: 1; transition: transform 160ms ease; }
.tx-row.is-expanded .tx-chevron { transform: rotate(180deg); }
.tx-expanded { padding: 0.7rem 0.85rem 0.9rem; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--accent-soft) 22%, var(--panel)); }
.tx-expanded .tx-category { margin-top: 0; }
.tx-merchant-history { margin-top: 0.55rem; padding: 0; border: 0; background: transparent; color: var(--accent); font: inherit; font-size: 0.86rem; font-weight: 700; cursor: pointer; }
.tx-merchant-history:hover { text-decoration: underline; }

@media (max-width: 720px) {
  .activity-link { margin-left: 0; flex: 1 1 100%; }
  .tx-summary { grid-template-columns: minmax(0, 1fr) auto auto; gap: 0.45rem; min-height: 3.35rem; }
  .tx-date { grid-row: 2; grid-column: 1; }
  .tx-account { grid-row: 2; grid-column: 2 / 4; text-align: right; }
  .tx-category-pill { display: none; }
  .tx-chevron { grid-column: 3; grid-row: 1; }
}
/* Money in & spending: household activity, not a cash-flow statement. */
.spending-summary { margin: 0 0 1rem; }
.spending-overview, .spending-categories { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.spending-overview { padding: 1rem; }
.spending-period { margin: 0 0 0.85rem; color: var(--muted); font-size: 0.9rem; font-weight: 700; }
.spending-totals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.spending-totals div { padding: 0.8rem; border-radius: var(--radius-sm); background: var(--bg-soft); }
.spending-totals span, .spending-category-head small { display: block; color: var(--muted); font-size: 0.78rem; font-weight: 600; }
.spending-totals strong { display: block; margin-top: 0.2rem; font-family: var(--mono); font-size: 1.12rem; }
.spending-explainer { margin: 0.85rem 0 0; color: var(--muted); font-size: 0.84rem; line-height: 1.45; }
.spending-categories { margin-top: 0.85rem; overflow: hidden; }
.spending-categories h2 { margin: 0; padding: 1rem; font-family: var(--font-display); font-size: 1.2rem; border-bottom: 1px solid var(--line); }
.spending-category + .spending-category { border-top: 1px solid var(--line); }
.spending-category-head, .spending-detail-row { width: 100%; border: 0; background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.spending-category-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; min-height: 3.8rem; padding: 0.75rem 1rem; }
.spending-category-head:hover, .spending-detail-row:hover { background: var(--bg-soft); }
.spending-category-head:focus-visible, .spending-detail-row:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }
.spending-category-total, .spending-detail-row strong { font-family: var(--mono); white-space: nowrap; }
.spending-category-detail { padding: 0 1rem 0.9rem; background: color-mix(in srgb, var(--accent-soft) 20%, var(--panel)); }
.spending-detail-label { margin: 0; padding: 0.8rem 0 0.35rem; color: var(--muted); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.spending-detail-row { display: flex; justify-content: space-between; gap: 0.75rem; padding: 0.58rem 0.35rem; border-radius: var(--radius-sm); font-size: 0.9rem; }
.spending-empty-detail { margin: 0; color: var(--muted); font-size: 0.88rem; }
@media (max-width: 720px) { .spending-totals { grid-template-columns: 1fr; } .spending-category-head { min-height: 4rem; } }
/* What changed in cash: settlement-aware companion to spending. */
.cash-movement { margin: 0 0 1rem; }
.cash-overview, .cash-sections { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.cash-overview { padding: 1rem; }
.cash-overview h2 { margin: 0; font-family: var(--font-display); font-size: 1.35rem; line-height: 1.25; }
.cash-detail { margin: 0.55rem 0 0; color: var(--muted); line-height: 1.45; }
.cash-bridge { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.65rem; margin-top: 1rem; }
.cash-bridge div { padding: 0.75rem; border-radius: var(--radius-sm); background: var(--bg-soft); }
.cash-bridge span { display: block; color: var(--muted); font-size: 0.76rem; font-weight: 700; }
.cash-bridge strong { display: block; margin-top: 0.2rem; font-family: var(--mono); font-size: 1rem; }
.cash-sections { margin-top: 0.85rem; overflow: hidden; }
.cash-sections h2 { margin: 0; padding: 1rem; font-family: var(--font-display); font-size: 1.2rem; border-bottom: 1px solid var(--line); }
.cash-section { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: 0.9rem 1rem; border-bottom: 1px solid var(--line); }
.cash-section strong { display: block; }
.cash-section p { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.88rem; }
.cash-section > span { font-family: var(--mono); font-weight: 600; white-space: nowrap; }
.cash-account-link { display: inline-flex; margin: 0.8rem 1rem 1rem; }
.cash-action { margin-top: 0.9rem; }
@media (max-width: 720px) { .cash-bridge { grid-template-columns: 1fr; } }