:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-soft: #f8faf7;
  --ink: #172033;
  --muted: #667085;
  --line: #dce3df;
  --line-strong: #c7d2cc;
  --brand: #155e75;
  --brand-strong: #164e63;
  --brand-soft: #e6f3f5;
  --accent: #b45309;
  --danger: #b42318;
  --success: #0f766e;
  --shadow-sm: 0 1px 2px rgba(20, 30, 46, .06);
  --shadow-md: 0 12px 28px rgba(20, 30, 46, .08);
  --sidebar-width: 14.25rem;
  --sidebar-collapsed-width: 4.7rem;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(230, 243, 245, .62), rgba(246, 247, 244, 0) 18rem),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-rendering: optimizeLegibility;
}

@supports (padding: max(0px)) {
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

button,
input,
select,
textarea {
  font: inherit;
}

a {
  color: inherit;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  border-right: 1px solid rgba(255,255,255,.1);
  background: #172033;
  color: #eef4f1;
  box-shadow: 20px 0 44px rgba(15, 23, 42, .13);
  transition: width .22s ease, transform .22s ease;
}

.brand-block {
  position: relative;
  display: flex;
  align-items: center;
  gap: .6rem;
  min-height: 4.95rem;
  padding: 1.05rem .78rem .95rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.brand-mark,
.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.brand-mark {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: .55rem;
  background: #d8f3f2;
  color: var(--brand-strong);
}

.brand-mark svg {
  width: 1.45rem;
  height: 1.45rem;
}

.brand-title {
  color: #fff;
  font-size: .98rem;
  font-weight: 760;
  line-height: 1.2;
}

.brand-subtitle,
.mobile-subtitle {
  color: #9aa8b8;
  font-size: .75rem;
  font-weight: 600;
  margin-top: .1rem;
}

.sidebar-collapse-button {
  display: inline-flex;
  width: 2rem;
  height: 2rem;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  border: 1px solid rgba(216, 243, 242, .22);
  border-radius: .45rem;
  background: rgba(216, 243, 242, .08);
  color: #d8f3f2;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}

.sidebar-collapse-button:hover {
  border-color: rgba(216, 243, 242, .42);
  background: rgba(216, 243, 242, .16);
  color: #fff;
}

.sidebar-collapse-button svg {
  width: 1.05rem;
  height: 1.05rem;
}

.collapse-icon-open {
  display: none;
}

.primary-nav {
  flex: 1;
  padding: .85rem .58rem;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-section + .nav-section {
  margin-top: 1.15rem;
}

.nav-section-label {
  padding: 0 .6rem .35rem;
  color: #8fa1b3;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

/* Navigation links */
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.62rem;
  min-height: 2.45rem;
  padding: 0.52rem 0.56rem;
  font-size: 0.875rem;
  font-weight: 650;
  color: #b7c2cf;
  border-radius: 0.45rem;
  margin: 0.1rem 0;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  text-decoration: none;
}

.nav-icon {
  width: 1.3rem;
  height: 1.3rem;
  color: currentColor;
}

.nav-icon svg {
  width: 1.2rem;
  height: 1.2rem;
}

.nav-link:hover {
  background: rgba(255,255,255,.07);
  color: #fff;
}

.nav-link.active {
  background: #f3f7f6;
  color: var(--brand-strong);
  box-shadow: var(--shadow-sm);
}

.nav-sublist {
  display: grid;
  gap: .1rem;
  margin: .1rem 0 .28rem 1.95rem;
}

.nav-sublink {
  display: inline-flex;
  align-items: center;
  min-height: 1.75rem;
  width: fit-content;
  padding: .16rem .45rem;
  border-radius: .35rem;
  color: #92a1b1;
  font-size: .76rem;
  font-weight: 700;
  text-decoration: none;
}

.nav-sublink:hover {
  background: rgba(255,255,255,.06);
  color: #fff;
}

.nav-sublink.active {
  background: rgba(216, 243, 242, .14);
  color: #d8f3f2;
}

.sidebar-footer {
  display: grid;
  gap: .65rem;
  margin: 0 .58rem .78rem;
  padding: .7rem .58rem;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: .5rem;
  color: #adc0c8;
  font-size: .75rem;
  font-weight: 650;
}

.install-app-button {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.install-app-button {
  width: 100%;
  justify-content: center;
  min-height: 2.2rem;
  border: 1px solid rgba(216, 243, 242, .26);
  border-radius: .45rem;
  background: rgba(216, 243, 242, .12);
  color: #e8fbfa;
  font-size: .78rem;
  font-weight: 760;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}

.install-app-button[hidden] {
  display: none;
}

.install-app-button:hover {
  border-color: rgba(216, 243, 242, .46);
  background: rgba(216, 243, 242, .2);
  color: #fff;
}

.install-app-button svg {
  width: 1rem;
  height: 1rem;
}

.app-main {
  min-width: 0;
  min-height: 100vh;
  flex: 1;
  margin-left: var(--sidebar-width);
  transition: margin-left .22s ease;
}

@media (min-width: 761px) {
  .sidebar-collapsed .app-sidebar {
    width: var(--sidebar-collapsed-width);
  }

  .sidebar-collapsed .app-main {
    margin-left: var(--sidebar-collapsed-width);
  }

  .sidebar-collapsed .brand-block {
    justify-content: center;
    padding-inline: .7rem;
  }

  .sidebar-collapsed .brand-block > div:not(.brand-mark),
  .sidebar-collapsed .nav-section-label,
  .sidebar-collapsed .install-app-button span {
    display: none;
  }

  .sidebar-collapsed .nav-link span:not(.nav-icon) {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .sidebar-collapsed .sidebar-collapse-button {
    position: absolute;
    top: 1.48rem;
    right: .42rem;
    width: 1.75rem;
    height: 1.75rem;
    background: #21304a;
    box-shadow: 0 4px 12px rgba(15,23,42,.18);
  }

  .sidebar-collapsed .collapse-icon-close {
    display: none;
  }

  .sidebar-collapsed .collapse-icon-open {
    display: block;
  }

  .sidebar-collapsed .primary-nav {
    padding-inline: .65rem;
  }

  .sidebar-collapsed .nav-section + .nav-section {
    margin-top: .75rem;
    padding-top: .75rem;
    border-top: 1px solid rgba(255,255,255,.1);
  }

  .sidebar-collapsed .nav-link {
    justify-content: center;
    gap: 0;
    min-height: 2.45rem;
    padding-inline: 0;
  }

  .sidebar-collapsed .nav-sublist {
    display: grid;
    grid-template-columns: 1fr;
    justify-items: center;
    gap: .18rem;
    margin: .22rem 0 .45rem;
  }

  .sidebar-collapsed .nav-sublink {
    justify-content: center;
    width: 2.45rem;
    min-height: 1.55rem;
    padding: 0;
    font-size: 0;
    font-weight: 800;
  }

  .sidebar-collapsed .nav-sublink::after {
    content: attr(data-short);
    font-size: .62rem;
    line-height: 1;
  }

  .sidebar-collapsed .sidebar-footer {
    justify-items: center;
    margin-inline: .65rem;
    padding: .65rem .35rem;
  }

  .sidebar-collapsed .install-app-button {
    justify-content: center;
    gap: 0;
  }

  .sidebar-collapsed .install-app-button {
    width: 2.25rem;
    padding: 0;
  }
}

.page-content {
  width: min(100%, 76rem);
  margin: 0 auto;
  padding: 2rem;
}

.mobile-topbar,
.sidebar-backdrop {
  display: none;
}

.icon-button {
  display: inline-flex;
  width: 2.4rem;
  height: 2.4rem;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.icon-button svg {
  width: 1.25rem;
  height: 1.25rem;
}

.install-guide {
  display: grid;
  gap: 1rem;
  color: var(--ink);
}

.install-guide-mark {
  display: inline-flex;
  width: 2.8rem;
  height: 2.8rem;
  align-items: center;
  justify-content: center;
  border-radius: .6rem;
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.install-guide-mark svg {
  width: 1.55rem;
  height: 1.55rem;
}

.install-guide h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.25;
}

.install-guide ol {
  display: grid;
  gap: .65rem;
  margin: 0;
  padding-left: 1.25rem;
  color: var(--muted);
  font-size: .93rem;
}

.install-guide li::marker {
  color: var(--brand);
  font-weight: 800;
}

.install-guide-close {
  justify-self: end;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  box-shadow: var(--shadow-sm);
  padding: 1.35rem;
}

/* Stat cards */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  box-shadow: var(--shadow-sm);
  padding: 1.05rem 1.15rem;
}
.stat-label { font-size: 0.74rem; color: var(--muted); font-weight: 750; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.7rem; font-weight: 780; margin-top: 0.25rem; color: var(--ink); letter-spacing: 0; }

/* Table */
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.data-table th {
  background: var(--surface-soft);
  text-align: left;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 0.78rem 1rem;
  border-bottom: 1px solid var(--line);
}
.data-table td { padding: 0.78rem 1rem; border-bottom: 1px solid #edf1ee; font-size: 0.875rem; vertical-align: middle; color: #263245; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fbfcfa; }

/* Amount colours */
.amount-neg { color: var(--danger); font-weight: 700; }
.amount-pos { color: var(--success); font-weight: 700; }

/* Badge */
.badge { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.22rem 0.6rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 700; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.35rem;
  padding: 0.52rem 0.95rem;
  border-radius: 0.45rem;
  font-size: 0.875rem;
  font-weight: 720;
  line-height: 1.2;
  cursor: pointer;
  border: 1px solid transparent;
  transition: color 0.15s, background 0.15s, border 0.15s, box-shadow 0.15s, transform 0.15s;
  text-decoration: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { cursor: not-allowed; opacity: .58; transform: none; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 8px 18px rgba(21, 94, 117, .18); }
.btn-primary:hover { background: var(--brand-strong); }
.btn-secondary { background: #fff; color: #354154; border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--surface-soft); border-color: #aebcb5; }
.btn-danger { background: #fff1f0; color: var(--danger); border-color: #f2b8b5; }
.btn-danger:hover { background: #ffe3e1; }

/* Transaction row actions */
.tx-row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
}
.tx-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 2rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--line-strong);
  border-radius: 0.45rem;
  background: #fff;
  color: #354154;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15,23,42,.06);
  transition: color 0.15s, background 0.15s, border 0.15s, box-shadow 0.15s, transform 0.15s;
}
.tx-action-btn:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-strong);
  box-shadow: 0 2px 6px rgba(21,94,117,.14);
}
.tx-action-btn:focus-visible {
  outline: 2px solid rgba(21,94,117,.35);
  outline-offset: 2px;
}
.tx-action-btn:active {
  transform: translateY(1px);
}
.tx-action-btn.is-active {
  border-color: #7cc6d4;
  background: var(--brand-soft);
  color: var(--brand-strong);
}
.tx-action-receipt.is-active {
  border-color: #82d8ca;
  background: #edfdfa;
  color: var(--success);
}

.transactions-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.tx-review-panel,
.tx-table-card {
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.tx-review-panel {
  padding: 1rem;
}

.tx-quick-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: .55rem;
  margin-bottom: 1rem;
}

.tx-review-chip {
  display: flex;
  min-width: 0;
  min-height: 4rem;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: .2rem;
  padding: .65rem .75rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--surface-soft);
  color: #354154;
  text-align: left;
  cursor: pointer;
  transition: background .15s, border .15s, box-shadow .15s, color .15s;
}

.tx-review-chip span {
  font-size: .84rem;
  font-weight: 790;
}

.tx-review-chip small {
  color: var(--muted);
  font-size: .7rem;
  font-weight: 620;
  line-height: 1.25;
}

.tx-review-chip:hover,
.tx-review-chip.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-strong);
  box-shadow: 0 0 0 2px rgba(21,94,117,.1);
}

/* Recurring review */
.recurring-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.recurring-controls {
  display: grid;
  min-width: 9.5rem;
  gap: .3rem;
}

.recurring-controls label,
.recurring-sort label {
  display: block;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 780;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.recurring-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .8rem;
  margin-bottom: 1rem;
}

.recurring-summary-tile,
.recurring-panel,
.recurring-row {
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.recurring-summary-tile {
  min-width: 0;
  padding: .95rem;
}

.recurring-summary-tile span {
  display: block;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 780;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.recurring-summary-tile strong {
  display: block;
  margin-top: .25rem;
  color: var(--ink);
  font-size: 1.45rem;
  font-weight: 820;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.recurring-summary-tile p {
  margin: .2rem 0 0;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 650;
}

.recurring-panel {
  padding: 1rem;
}

.recurring-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .9rem;
}

.recurring-toolbar span {
  display: block;
  color: var(--brand-strong);
  font-size: .72rem;
  font-weight: 820;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.recurring-toolbar h2 {
  margin: .15rem 0 0;
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 820;
  line-height: 1.2;
}

.recurring-toolbar p {
  margin: .28rem 0 0;
  color: var(--muted);
  font-size: .86rem;
  line-height: 1.35;
}

.recurring-sort {
  display: grid;
  flex: 0 0 12rem;
  gap: .3rem;
}

.recurring-filter-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .55rem;
  margin-bottom: .9rem;
}

.recurring-filter-chip {
  display: flex;
  min-width: 0;
  min-height: 3.7rem;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: .18rem;
  padding: .62rem .72rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--surface-soft);
  color: #354154;
  text-align: left;
  cursor: pointer;
  transition: background .15s, border .15s, box-shadow .15s, color .15s;
}

.recurring-filter-chip span {
  font-size: .84rem;
  font-weight: 790;
}

.recurring-filter-chip small {
  color: var(--muted);
  font-size: .7rem;
  font-weight: 620;
  line-height: 1.25;
}

.recurring-filter-chip:hover,
.recurring-filter-chip.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-strong);
  box-shadow: 0 0 0 2px rgba(21,94,117,.1);
}

.recurring-list {
  display: grid;
  gap: .65rem;
}

.recurring-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(18rem, 1fr) auto;
  align-items: center;
  gap: .85rem;
  padding: .85rem;
}

.recurring-main {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: .42rem;
}

.recurring-merchant {
  min-width: 0;
}

.recurring-merchant strong {
  display: block;
  color: var(--ink);
  font-size: .95rem;
  font-weight: 780;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.recurring-merchant span {
  display: block;
  margin-top: .18rem;
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.35;
}

.recurring-badge {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  border-radius: 999px;
  padding: .2rem .55rem;
  font-size: .72rem;
  font-weight: 780;
}

.recurring-badge.pattern-fixed {
  background: #e6f3f5;
  color: var(--brand-strong);
}

.recurring-badge.pattern-variable {
  background: #fef3c7;
  color: #92400e;
}

.recurring-badge.pattern-irregular {
  background: #eef2f6;
  color: #475467;
}

.recurring-amounts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .55rem;
}

.recurring-amounts div {
  min-width: 0;
}

.recurring-amounts span {
  display: block;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 760;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.recurring-amounts strong {
  display: block;
  margin-top: .12rem;
  color: var(--ink);
  font-size: .9rem;
  font-weight: 800;
  white-space: nowrap;
}

.recurring-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .45rem;
}

.recurring-detail {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
  padding-top: .75rem;
}

.recurring-detail-title {
  margin-bottom: .45rem;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 780;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.recurring-months {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
}

.recurring-months span {
  display: inline-flex;
  align-items: center;
  gap: .38rem;
  border: 1px solid var(--line);
  border-radius: .45rem;
  background: var(--surface-soft);
  padding: .38rem .55rem;
}

.recurring-months small {
  color: var(--muted);
  font-size: .75rem;
  font-weight: 650;
}

.recurring-months b {
  color: var(--ink);
  font-size: .78rem;
  font-weight: 800;
}

.recurring-list-foot {
  display: flex;
  justify-content: center;
  margin-top: .85rem;
}

.recurring-empty {
  display: grid;
  justify-items: center;
  gap: .4rem;
  padding: 3rem 1rem;
  text-align: center;
}

.tx-filter-grid {
  display: grid;
  grid-template-columns: minmax(8rem, .7fr) minmax(11rem, .9fr) minmax(7rem, .65fr) minmax(8rem, .65fr) minmax(12rem, 1.4fr) auto;
  gap: .7rem;
  align-items: end;
}

.tx-filter-field,
.tx-filter-actions {
  min-width: 0;
}

.tx-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  margin-bottom: .25rem;
}

.tx-field-link {
  color: var(--brand-strong);
  font-size: .72rem;
  font-weight: 780;
  text-decoration: none;
}

.tx-field-link:hover {
  text-decoration: underline;
}

.tx-filter-actions {
  display: flex;
  gap: .45rem;
}

.tx-table-card {
  overflow: hidden;
}

.tx-table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  min-height: 4rem;
  padding: .8rem 1rem;
  border-bottom: 1px solid var(--line);
}

.tx-result-count {
  color: var(--ink);
  font-size: .92rem;
  font-weight: 790;
}

.tx-active-filter {
  margin-top: .08rem;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 620;
}

.tx-bulk-bar,
.tx-pagination {
  display: flex;
  align-items: center;
  gap: .45rem;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
}

.tx-bulk-bar {
  margin-left: auto;
  padding: .45rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--surface-soft);
}

.tx-bulk-bar .input {
  width: 12rem;
  min-height: 2rem;
  padding-block: .3rem;
}

.tx-table-scroll {
  overflow-x: auto;
}

.tx-review-table th,
.tx-review-table td {
  white-space: normal;
}

.tx-select-col {
  width: 2.75rem;
  text-align: center !important;
}

.tx-select-col input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--brand);
}

.tx-merchant-cell {
  min-width: 14rem;
}

.tx-merchant-line {
  display: flex;
  align-items: center;
  gap: .45rem;
  min-width: 0;
}

.tx-merchant {
  color: var(--ink);
  font-weight: 760;
  overflow-wrap: anywhere;
}

.tx-alert-dot {
  width: .5rem;
  height: .5rem;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(180,83,9,.12);
  flex: 0 0 auto;
}

.tx-description,
.tx-note-preview {
  margin-top: .14rem;
  color: var(--muted);
  font-size: .74rem;
  line-height: 1.35;
}

.tx-description {
  max-width: 28rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tx-note-preview {
  color: var(--brand-strong);
  font-weight: 650;
  overflow-wrap: anywhere;
}

.tx-meta-col {
  min-width: 13rem;
}

.tx-badge-stack {
  display: flex;
  flex-wrap: wrap;
  gap: .28rem;
}

.tx-review-badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.35rem;
  max-width: 12rem;
  padding: .14rem .48rem;
  border-radius: 999px;
  background: #eef2f0;
  color: #526071;
  font-size: .68rem;
  font-weight: 780;
  line-height: 1.1;
}

.tx-review-badge.category {
  background: color-mix(in srgb, var(--tx-badge-color) 14%, white);
  color: var(--tx-badge-color);
}

.tx-review-badge.warning {
  background: #fff4df;
  color: #9a5b00;
}

.tx-review-badge.card {
  background: #f1eafe;
  color: #6d28d9;
}

.tx-review-badge.source {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.tx-review-badge.person {
  background: #eff6ff;
  color: #2563eb;
}

.tx-review-badge.note {
  background: #eef2ff;
  color: #4338ca;
}

.tx-review-badge.receipt {
  background: #edfdfa;
  color: var(--success);
}

@media (max-width: 760px) {
  .tx-row-actions {
    min-width: 0;
  }
  .tx-action-btn {
    padding-inline: 0.5rem;
  }
}

/* Input */
.input {
  width: 100%;
  min-height: 2.35rem;
  padding: 0.5rem 0.72rem;
  border: 1px solid var(--line-strong);
  border-radius: 0.45rem;
  background: #fff;
  color: var(--ink);
  font-size: 0.875rem;
  outline: none;
  transition: border 0.15s, box-shadow 0.15s, background 0.15s;
}
.input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(21,94,117,.14);
}
.input::placeholder {
  color: #98a2b3;
}

/* Progress bar */
.progress-bar { height: 8px; border-radius: 9999px; background: #e2e8f0; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 9999px; transition: width 0.4s; }

/* Upload drop zone */
.drop-zone {
  border: 1.5px dashed var(--line-strong);
  border-radius: 0.5rem;
  padding: 3rem 2rem;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
  background: var(--surface-soft);
}
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--brand); background: var(--brand-soft); }

/* Documents */
.documents-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.documents-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .5rem;
}

.documents-stats,
.documents-layout {
  display: grid;
  gap: 1rem;
}

.documents-stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 1rem;
}

.documents-stat-hint {
  margin-top: .2rem;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 650;
}

.documents-layout {
  grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr);
  margin-bottom: 1rem;
}

.documents-import-panel,
.documents-review-panel,
.documents-history,
.documents-statements {
  min-width: 0;
  padding: 1.1rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.documents-drop {
  padding: 2.2rem 1.4rem;
}

.doc-drop-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  margin-bottom: .8rem;
  border: 1px solid #b8d8dd;
  border-radius: .5rem;
  background: #fff;
  color: var(--brand-strong);
  font-size: .72rem;
  font-weight: 850;
}

.documents-secondary-upload {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  margin-top: .8rem;
  padding: .85rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--surface-soft);
}

.documents-secondary-upload strong,
.documents-review-row strong,
.documents-history-row strong,
.documents-statement-row strong {
  display: block;
  color: var(--ink);
  font-size: .9rem;
  font-weight: 780;
  overflow-wrap: anywhere;
}

.documents-secondary-upload span,
.documents-review-row p,
.documents-history-row p,
.documents-statement-row p {
  display: block;
  margin-top: .15rem;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.35;
}

.documents-status {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin-top: .8rem;
  padding: .75rem .85rem;
  border-radius: .5rem;
  font-size: .84rem;
  font-weight: 650;
}

.documents-status .tiny {
  width: 1rem;
  height: 1rem;
  border-width: 2px;
}

.documents-status span {
  color: inherit;
}

.documents-status.working {
  border: 1px solid #b8d8dd;
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.documents-status.success {
  border: 1px solid #a4e7d7;
  background: #edfdfa;
  color: var(--success);
}

.documents-status.error {
  border: 1px solid #f2b8b5;
  background: #fff1f0;
  color: var(--danger);
}

.documents-review-list,
.documents-timeline,
.documents-statement-list {
  display: grid;
  gap: .6rem;
}

.documents-review-row,
.documents-history-row,
.documents-statement-row {
  display: grid;
  align-items: center;
  gap: .75rem;
  min-width: 0;
  padding: .8rem;
  border: 1px solid #e8eeeb;
  border-radius: .45rem;
  background: var(--surface-soft);
  text-decoration: none;
  transition: border .15s, background .15s, transform .15s;
}

.documents-review-row {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.documents-history-row {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.documents-statement-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.documents-review-row:hover,
.documents-history-row:hover,
.documents-statement-row:hover {
  border-color: var(--brand);
  background: #fff;
  transform: translateY(-1px);
}

.doc-type,
.doc-kind,
.documents-status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.5rem;
  padding: .18rem .55rem;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 820;
  white-space: nowrap;
}

.doc-type,
.doc-kind.statement {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.doc-kind.receipt {
  background: #f1eafe;
  color: #6d28d9;
}

.documents-review-row b {
  color: var(--brand-strong);
  font-size: .78rem;
  font-weight: 800;
}

.documents-status-pill.ok {
  background: #edfdfa;
  color: var(--success);
}

.documents-status-pill.warning {
  background: #fff4df;
  color: #9a5b00;
}

.documents-empty {
  padding: 1rem;
  border: 1px dashed var(--line-strong);
  border-radius: .45rem;
  color: var(--muted);
  font-size: .84rem;
  text-align: center;
}

/* Settings */
.settings-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .5rem;
}

.settings-loading {
  display: flex;
  min-height: 16rem;
  align-items: center;
  justify-content: center;
}

.settings-overview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.settings-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(18rem, .34fr);
  gap: 1rem;
  align-items: start;
}

.settings-main,
.settings-side,
.settings-category-groups,
.settings-category-list,
.settings-rule-list,
.settings-action-list,
.settings-statement-list {
  display: grid;
  gap: .85rem;
}

.settings-panel,
.settings-category-group {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.settings-panel {
  padding: 1.1rem;
}

.settings-category-group {
  padding: .85rem;
  background: var(--surface-soft);
}

.settings-group-head,
.settings-category-row,
.settings-rule-row,
.settings-action-row,
.settings-statement-row {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.settings-group-head {
  justify-content: space-between;
  margin-bottom: .75rem;
}

.settings-group-head strong {
  color: var(--ink);
  font-size: .95rem;
  font-weight: 790;
}

.settings-group-head .btn {
  min-height: 2rem;
  padding: .32rem .65rem;
  font-size: .78rem;
}

.settings-category-row,
.settings-rule-row,
.settings-action-row,
.settings-statement-row {
  min-width: 0;
  padding: .75rem;
  border: 1px solid #e8eeeb;
  border-radius: .45rem;
  background: #fff;
}

.settings-action-row,
.settings-statement-row {
  text-decoration: none;
  transition: border .15s, background .15s, transform .15s;
}

.settings-action-row:hover,
.settings-statement-row:hover {
  border-color: var(--brand);
  background: var(--surface-soft);
  transform: translateY(-1px);
}

.settings-category-icon {
  display: inline-flex;
  width: 2.25rem;
  height: 2.25rem;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: .45rem;
  font-size: 1.05rem;
  font-weight: 800;
}

.settings-category-copy,
.settings-rule-row div,
.settings-action-row span,
.settings-statement-row span {
  min-width: 0;
  flex: 1;
}

.settings-category-copy strong,
.settings-rule-row strong,
.settings-action-row strong,
.settings-statement-row strong {
  display: block;
  color: var(--ink);
  font-size: .9rem;
  font-weight: 780;
  overflow-wrap: anywhere;
}

.settings-category-copy small,
.settings-rule-row span,
.settings-action-row small,
.settings-statement-row small,
.settings-note {
  display: block;
  margin-top: .12rem;
  color: var(--muted);
  font-size: .76rem;
  line-height: 1.35;
}

.settings-row-actions {
  display: flex;
  flex: 0 0 auto;
  gap: .35rem;
}

.settings-row-actions .icon-button,
.settings-rule-row .icon-button {
  width: 2.1rem;
  height: 2.1rem;
  box-shadow: none;
}

.icon-button.danger {
  color: var(--danger);
}

.icon-button.danger:hover {
  border-color: #f2b8b5;
  background: #fff1f0;
}

.settings-action-row b {
  color: var(--brand-strong);
  font-size: 1.35rem;
  line-height: 1;
}

.settings-statement-row b {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.55rem;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 820;
  white-space: nowrap;
}

.settings-statement-row b.ok {
  background: #edfdfa;
  color: var(--success);
}

.settings-statement-row b.warning {
  background: #fff4df;
  color: #9a5b00;
}

.settings-person-list {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
}

.settings-person-list span {
  display: inline-flex;
  align-items: center;
  min-height: 1.8rem;
  padding: .25rem .65rem;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: .78rem;
  font-weight: 780;
}

.settings-empty {
  padding: .9rem;
  border: 1px dashed var(--line-strong);
  border-radius: .45rem;
  color: var(--muted);
  font-size: .84rem;
  text-align: center;
}

.settings-colour-input {
  width: 3rem;
  height: 2.35rem;
  flex: 0 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: .45rem;
  background: #fff;
  cursor: pointer;
}

@media (max-width: 980px) {
  .documents-header {
    align-items: flex-start;
    flex-direction: column;
  }
  .documents-actions {
    justify-content: flex-start;
  }
  .documents-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .documents-layout {
    grid-template-columns: 1fr;
  }
  .settings-header {
    align-items: flex-start;
    flex-direction: column;
  }
  .settings-actions {
    justify-content: flex-start;
  }
  .settings-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .documents-stats {
    grid-template-columns: 1fr;
  }
  .settings-overview {
    grid-template-columns: 1fr;
  }
  .settings-actions,
  .settings-actions .btn {
    width: 100%;
  }
  .settings-panel {
    padding: .9rem;
  }
  .settings-category-row,
  .settings-rule-row,
  .settings-action-row,
  .settings-statement-row {
    align-items: flex-start;
  }
  .settings-category-row,
  .settings-rule-row {
    flex-wrap: wrap;
  }
  .settings-row-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .documents-actions,
  .documents-actions .btn {
    width: 100%;
  }
  .documents-review-row,
  .documents-history-row {
    grid-template-columns: 1fr;
    align-items: flex-start;
  }
  .documents-statement-row {
    grid-template-columns: 1fr;
  }
  .documents-status-pill,
  .documents-review-row b {
    width: fit-content;
  }
}

/* Month picker */
.month-btn {
  min-height: 2rem;
  padding: 0.35rem 0.75rem;
  border-radius: 0.45rem;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: #344054;
  transition: all 0.15s;
}
.month-btn:hover { border-color: var(--brand); color: var(--brand-strong); }
.month-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Page title */
.page-title {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: 0;
}

/* Overview */
.overview-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.overview-subtitle {
  margin-top: .25rem;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 560;
}

.month-picker {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .45rem;
}

.money-story {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(17rem, .75fr);
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 1.45rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.money-story.positive {
  border-top: 4px solid var(--success);
}

.money-story.negative {
  border-top: 4px solid var(--danger);
}

.story-kicker {
  color: var(--brand-strong);
  font-size: .74rem;
  font-weight: 820;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.story-main h1 {
  max-width: 48rem;
  margin: .35rem 0 .55rem;
  color: var(--ink);
  font-size: clamp(1.7rem, 3vw, 2.55rem);
  font-weight: 830;
  line-height: 1.08;
  letter-spacing: 0;
}

.story-main p,
.signal-copy,
.story-insight p,
.investment-copy {
  color: #526071;
  font-size: .95rem;
  line-height: 1.55;
}

.story-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .65rem;
  margin-top: 1.1rem;
}

.story-metrics div,
.story-side,
.health-card,
.overview-panel,
.expense-split {
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--surface);
}

.story-metrics div {
  padding: .85rem;
  background: var(--surface-soft);
}

.story-metrics span,
.health-card span,
.panel-head span,
.driver-row span,
.story-insight span {
  display: block;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 780;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.story-metrics strong {
  display: block;
  margin-top: .25rem;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 790;
}

.story-side {
  display: flex;
  flex-direction: column;
  gap: .9rem;
  padding: 1rem;
  background: var(--surface-soft);
}

.signal-pill {
  width: fit-content;
  border-radius: 999px;
  padding: .32rem .72rem;
  font-size: .78rem;
  font-weight: 780;
}

.signal-pill.warning {
  background: #fff4df;
  color: #9a5b00;
}

.signal-pill.positive {
  background: #dcf8ef;
  color: var(--success);
}

.signal-pill.neutral {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.story-insight {
  padding-top: .85rem;
  border-top: 1px solid var(--line);
}

.story-insight strong {
  display: block;
  margin-top: .25rem;
  color: var(--ink);
  font-size: .98rem;
  font-weight: 780;
}

.story-insight p {
  margin: .25rem 0 0;
  font-size: .86rem;
}

.story-insight.muted strong {
  color: #475467;
}

.overview-grid {
  display: grid;
  gap: 1rem;
  margin-bottom: 1rem;
}

.overview-grid-health {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.overview-grid-main {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.health-card {
  min-height: 8.2rem;
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}

.health-card strong {
  display: block;
  margin-top: .35rem;
  color: var(--ink);
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.health-card p {
  margin: .45rem 0 0;
  color: #667085;
  font-size: .8rem;
  line-height: 1.35;
}

.health-card.positive {
  border-top: 3px solid var(--success);
}

.health-card.positive strong {
  color: var(--success);
}

.health-card.negative {
  border-top: 3px solid var(--danger);
}

.health-card.negative strong {
  color: var(--danger);
}

.health-card.neutral {
  border-top: 3px solid var(--brand);
}

.health-card .positive,
.story-metrics .positive {
  color: var(--success);
}

.health-card .negative,
.story-metrics .negative {
  color: var(--danger);
}

.expense-split {
  padding: .9rem 1rem;
  margin-bottom: 1rem;
}

.split-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .65rem;
}

.split-head strong {
  color: var(--ink);
  font-size: .9rem;
  font-weight: 780;
}

.split-head span {
  color: var(--muted);
  font-size: .82rem;
  font-weight: 620;
}

.split-bar {
  display: flex;
  height: .62rem;
  overflow: hidden;
  border-radius: 999px;
  background: #e7ece9;
}

.split-bar .card-part {
  background: #64748b;
}

.split-bar .bank-part {
  background: var(--danger);
}

.overview-panel {
  min-width: 0;
  padding: 1.1rem;
  box-shadow: var(--shadow-sm);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.panel-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0;
}

.panel-head p {
  margin: .18rem 0 0;
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.35;
}

.panel-head > span {
  flex: 0 0 auto;
  padding-top: .1rem;
  color: var(--brand-strong);
}

.driver-list,
.opportunity-list,
.action-list {
  display: grid;
  gap: .65rem;
}

.driver-row,
.opportunity-row,
.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .9rem;
  min-width: 0;
  padding: .8rem;
  border: 1px solid #e8eeeb;
  border-radius: .45rem;
  background: var(--surface-soft);
}

.driver-row strong,
.opportunity-row strong,
.action-row strong {
  display: block;
  color: var(--ink);
  font-size: .92rem;
  font-weight: 760;
  overflow-wrap: anywhere;
}

.driver-row p,
.opportunity-row span,
.action-row span {
  display: block;
  margin-top: .15rem;
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.35;
}

.driver-row b,
.opportunity-row b {
  flex: 0 0 auto;
  color: var(--ink);
  font-size: .9rem;
  font-weight: 790;
  white-space: nowrap;
}

.chart-panel {
  min-height: 19.5rem;
}

.chart-frame {
  position: relative;
  height: 14.5rem;
}

.chart-fallback {
  display: grid;
  gap: .55rem;
  height: 100%;
  align-content: center;
}

.chart-fallback-row {
  display: grid;
  grid-template-columns: minmax(4.5rem, .8fr) minmax(5rem, 1.4fr) minmax(5.5rem, .7fr);
  align-items: center;
  gap: .55rem;
  min-width: 0;
  color: var(--muted);
  font-size: .75rem;
}

.chart-fallback-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-fallback-row b {
  color: var(--ink);
  font-size: .75rem;
  font-weight: 760;
  text-align: right;
  white-space: nowrap;
}

.chart-fallback-track {
  height: .5rem;
  overflow: hidden;
  border-radius: 999px;
  background: #e7ece9;
}

.chart-fallback-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}

.investment-teaser {
  background: linear-gradient(180deg, #fff, #f7fbfa);
}

.investment-number {
  color: var(--brand-strong);
  font-size: 2rem;
  font-weight: 840;
  line-height: 1.05;
}

.investment-copy {
  max-width: 34rem;
  margin: .55rem 0 1rem;
  font-size: .88rem;
}

.action-row {
  color: inherit;
  text-decoration: none;
  transition: border .15s, background .15s, transform .15s;
}

.action-row:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
  transform: translateY(-1px);
}

.action-row svg {
  flex: 0 0 auto;
  width: 1.15rem;
  height: 1.15rem;
  color: var(--brand-strong);
}

.empty-state {
  padding: 1rem;
  border: 1px dashed var(--line-strong);
  border-radius: .5rem;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.5;
}

.overview-empty {
  display: flex;
  min-height: 28rem;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .8rem;
  text-align: center;
}

.empty-icon {
  display: inline-flex;
  width: 3.5rem;
  height: 3.5rem;
  align-items: center;
  justify-content: center;
  border-radius: .6rem;
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.empty-icon svg {
  width: 2rem;
  height: 2rem;
}

.empty-copy {
  max-width: 28rem;
  color: var(--muted);
  font-size: .95rem;
  line-height: 1.5;
}

/* Plan */
.plan-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.plan-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: .6rem;
}

.plan-controls .input {
  width: 12.5rem;
}

.plan-story {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(18rem, .85fr);
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 1.45rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.plan-story.positive {
  border-top: 4px solid var(--success);
}

.plan-story.negative {
  border-top: 4px solid var(--danger);
}

.plan-stack {
  display: flex;
  height: .8rem;
  margin-top: 1.15rem;
  overflow: hidden;
  border-radius: 999px;
  background: #e7ece9;
}

.plan-stack span {
  display: block;
  min-width: .25rem;
}

.plan-stack .plan-fixed-part,
.plan-legend .plan-fixed-part {
  background: #475467;
}

.plan-stack .plan-flexible-part,
.plan-legend .plan-flexible-part {
  background: var(--brand);
}

.plan-stack .plan-savings-part,
.plan-legend .plan-savings-part {
  background: var(--success);
}

.plan-legend {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-top: .7rem;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 650;
}

.plan-legend span {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}

.plan-legend i {
  display: inline-block;
  flex: 0 0 auto;
  width: .55rem;
  height: .55rem;
  border-radius: 999px;
}

.plan-side {
  display: grid;
  gap: .7rem;
}

.plan-summary-tile,
.plan-panel {
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.plan-summary-tile {
  padding: .95rem;
}

.plan-summary-tile span,
.savings-editor label,
.budget-edit label {
  display: block;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 780;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.plan-summary-tile strong {
  display: block;
  margin-top: .25rem;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.plan-summary-tile.positive strong {
  color: var(--success);
}

.plan-summary-tile.negative strong {
  color: var(--danger);
}

.plan-summary-tile p {
  margin: .35rem 0 0;
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.35;
}

.plan-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(19rem, .85fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

.plan-panel {
  min-width: 0;
  margin-bottom: 1rem;
  padding: 1.1rem;
}

.panel-head b {
  flex: 0 0 auto;
  color: var(--brand-strong);
  font-size: 1.05rem;
  font-weight: 820;
  white-space: nowrap;
}

.commitment-list,
.goal-list,
.plan-budget-list,
.adjustment-list {
  display: grid;
  gap: .65rem;
}

.commitment-row,
.goal-row,
.plan-budget-row,
.adjustment-row {
  min-width: 0;
  border: 1px solid #e8eeeb;
  border-radius: .45rem;
  background: var(--surface-soft);
}

.commitment-row,
.goal-row,
.adjustment-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .9rem;
  padding: .8rem;
}

.commitment-row strong,
.goal-row strong,
.plan-budget-row strong,
.adjustment-row strong {
  display: block;
  color: var(--ink);
  font-size: .92rem;
  font-weight: 760;
  overflow-wrap: anywhere;
}

.commitment-row span,
.goal-row span,
.plan-budget-row span,
.adjustment-row span {
  display: block;
  margin-top: .18rem;
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.35;
}

.commitment-row b,
.goal-row b,
.adjustment-row b {
  flex: 0 0 auto;
  color: var(--ink);
  font-size: .92rem;
  font-weight: 790;
  white-space: nowrap;
}

.savings-editor {
  display: grid;
  gap: .4rem;
  margin-bottom: .85rem;
}

.savings-editor > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .55rem;
}

.plan-budget-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(13.5rem, auto);
  align-items: center;
  gap: .9rem;
  padding: .85rem;
}

.budget-main {
  min-width: 0;
}

.budget-main .progress-bar {
  margin-top: .55rem;
}

.budget-edit {
  display: grid;
  grid-template-columns: minmax(6.5rem, 7.5rem) auto;
  gap: .45rem;
  align-items: end;
}

.budget-edit label {
  grid-column: 1 / -1;
}

.plan-panel-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: .8rem;
}

.adjustment-row {
  color: inherit;
  text-decoration: none;
  transition: border .15s, background .15s, transform .15s;
}

.adjustment-row:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
  transform: translateY(-1px);
}

/* Investment projection */
.investment-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.investment-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .6rem;
}

.investment-workbench {
  display: grid;
  grid-template-columns: minmax(18rem, .72fr) minmax(0, 1.55fr);
  gap: 1rem;
  align-items: start;
}

.investment-controls-panel,
.investment-result-panel,
.projection-story,
.projection-chart-panel,
.scenario-card,
.investment-education,
.assumption-list {
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.investment-controls-panel {
  position: sticky;
  top: 1rem;
  display: grid;
  gap: 1rem;
  padding: 1.1rem;
}

.investment-result-panel {
  min-width: 0;
  padding: 1rem;
}

.investment-field {
  display: grid;
  gap: .45rem;
}

.investment-field span,
.projection-story span,
.scenario-card span,
.investment-education span {
  display: block;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 780;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.range-head {
  display: flex;
  justify-content: flex-end;
  min-height: 1.3rem;
}

.range-head output {
  color: var(--ink);
  font-size: .9rem;
  font-weight: 790;
}

.investment-range {
  width: 100%;
  accent-color: var(--brand);
}

.projection-story {
  margin-bottom: 1rem;
  padding: 1.25rem;
  border-top: 4px solid var(--success);
  background: linear-gradient(180deg, #fff, #f7fbfa);
}

.projection-story strong {
  display: block;
  margin: .35rem 0 .45rem;
  color: var(--brand-strong);
  font-size: clamp(1.8rem, 3vw, 2.65rem);
  font-weight: 840;
  line-height: 1.05;
}

.projection-story p,
.scenario-card p,
.investment-education p {
  margin: 0;
  color: #526071;
  font-size: .9rem;
  line-height: 1.5;
}

.projection-chart-panel {
  margin-bottom: 1rem;
  padding: 1.1rem;
}

.investment-chart-frame {
  height: 17rem;
}

.projection-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .75rem;
  margin-bottom: 1rem;
}

.scenario-card {
  min-width: 0;
  padding: 1rem;
}

.scenario-card strong,
.investment-education strong {
  display: block;
  margin: .35rem 0 .35rem;
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.scenario-card:nth-child(1) {
  border-top: 3px solid #475467;
}

.scenario-card:nth-child(2) {
  border-top: 3px solid var(--brand);
}

.scenario-card:nth-child(3) {
  border-top: 3px solid var(--success);
}

.investment-education {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .8rem;
  margin-bottom: 1rem;
  padding: 1rem;
  background: var(--surface-soft);
}

.assumption-list {
  display: grid;
  gap: .5rem;
  padding: 1rem;
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.45;
}

.assumption-list div {
  padding-left: .8rem;
  border-left: 3px solid var(--line-strong);
}

.defi-radar-panel {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.defi-radar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .9rem;
}

.section-kicker {
  margin-bottom: .2rem;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 780;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.defi-radar-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 830;
  line-height: 1.2;
}

.defi-radar-head p {
  margin: .35rem 0 0;
  color: #526071;
  font-size: .9rem;
  line-height: 1.45;
}

.defi-disclaimer {
  margin-bottom: .9rem;
  padding: .75rem .85rem;
  border-left: 3px solid var(--accent);
  border-radius: .45rem;
  background: #fff8ed;
  color: #78350f;
  font-size: .85rem;
  line-height: 1.45;
}

.defi-method {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  margin-bottom: .9rem;
  padding: .75rem .85rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--surface-soft);
  color: #526071;
  font-size: .82rem;
}

.defi-method strong {
  color: var(--ink);
  font-weight: 820;
}

.defi-method span {
  padding: .18rem .45rem;
  border-radius: .35rem;
  background: #fff;
  color: var(--muted);
  font-weight: 700;
}

.defi-filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: .75rem;
  align-items: end;
  margin-bottom: 1rem;
}

.defi-checkbox {
  display: flex;
  align-items: center;
  min-height: 2.7rem;
  gap: .45rem;
  color: var(--ink);
  font-size: .88rem;
  font-weight: 700;
}

.defi-checkbox input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--brand);
}

.defi-meta-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .6rem;
  margin-bottom: .75rem;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
}

.defi-warning-list {
  display: grid;
  gap: .4rem;
  margin-bottom: .9rem;
}

.defi-warning-list div,
.defi-empty-state {
  padding: .8rem .9rem;
  border: 1px solid #fed7aa;
  border-radius: .5rem;
  background: #fff7ed;
  color: #9a3412;
  font-size: .88rem;
  line-height: 1.45;
}

.defi-top-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: .7rem;
  margin-bottom: 1rem;
}

.defi-pool-card {
  position: relative;
  display: grid;
  gap: .7rem;
  min-width: 0;
  padding: .9rem;
  border: 1px solid var(--line);
  border-top: 3px solid var(--brand);
  border-radius: .5rem;
  background: var(--surface-soft);
}

.defi-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
}

.defi-card-rank {
  color: var(--brand-strong);
  font-size: .8rem;
  font-weight: 850;
}

.defi-card-main span,
.defi-muted {
  color: var(--muted);
  font-size: .74rem;
  font-weight: 740;
}

.defi-card-main strong {
  display: block;
  margin: .2rem 0;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 830;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.defi-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin: .35rem 0;
}

.defi-chip-row i {
  display: inline-flex;
  align-items: center;
  min-height: 1.45rem;
  padding: .15rem .45rem;
  border-radius: .35rem;
  background: #fff;
  color: var(--brand-strong);
  font-size: .72rem;
  font-style: normal;
  font-weight: 800;
}

.defi-card-main p {
  margin: 0;
  color: #526071;
  font-size: .8rem;
  line-height: 1.35;
}

.defi-detail-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 2rem;
  margin-top: .55rem;
  padding: .35rem .65rem;
  border: 1px solid var(--line);
  border-radius: .4rem;
  background: #fff;
  color: var(--brand-strong);
  font-size: .78rem;
  font-weight: 850;
  text-decoration: none;
}

.defi-detail-link:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.defi-detail-link-compact {
  min-height: 1.45rem;
  margin-top: 0;
  padding: .12rem .38rem;
  font-size: .72rem;
}

.defi-card-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .45rem;
}

.defi-card-metrics span {
  min-width: 0;
  padding: .45rem;
  border: 1px solid var(--line);
  border-radius: .45rem;
  background: #fff;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 700;
}

.defi-card-metrics b {
  display: block;
  color: var(--ink);
  font-size: .9rem;
  font-weight: 850;
}

.defi-analysis {
  display: grid;
  gap: .3rem;
}

.defi-analysis strong {
  color: var(--ink);
  font-size: .78rem;
  font-weight: 830;
}

.defi-analysis p,
.defi-analysis ul {
  margin: 0;
  color: #526071;
  font-size: .8rem;
  line-height: 1.4;
}

.defi-analysis ul {
  display: grid;
  gap: .25rem;
  padding-left: 1rem;
}

.defi-score {
  justify-self: start;
  padding: .2rem .45rem;
  border-radius: .35rem;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: .8rem;
  font-weight: 850;
}

.defi-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: .5rem;
}

.defi-table {
  width: 100%;
  min-width: 79rem;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: .84rem;
}

.defi-table th,
.defi-table td {
  padding: .7rem .75rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.defi-table th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.defi-table th:first-child,
.defi-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  border-right: 1px solid var(--line);
}

.defi-table th:first-child {
  z-index: 2;
}

.defi-table td:first-child {
  background: #fff;
}

.defi-table tbody tr:nth-child(even) td {
  background: #fbfcfd;
}

.defi-table tbody tr:nth-child(even) td:first-child {
  background: #fbfcfd;
}

.defi-table tbody tr:hover td {
  background: #f6fafb;
}

.defi-sort-button {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: .45rem;
  width: 100%;
  min-height: 1.75rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  letter-spacing: inherit;
  text-align: left;
  text-transform: inherit;
}

.defi-sort-button:hover,
.defi-sort-button.active {
  color: var(--brand-strong);
}

.defi-sort-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  min-height: 1rem;
  padding: 0 .25rem;
  border-radius: .25rem;
  background: transparent;
  color: var(--muted);
  font-size: .62rem;
  font-weight: 850;
  letter-spacing: 0;
}

.defi-sort-button.active .defi-sort-marker {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.defi-table tbody tr:last-child td {
  border-bottom: 0;
}

.defi-pair {
  color: var(--ink);
  font-weight: 820;
  overflow-wrap: anywhere;
}

.defi-pool-cell {
  vertical-align: top;
}

.defi-pool-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem;
  margin-top: .18rem;
  color: var(--muted);
  font-size: .74rem;
  font-weight: 740;
}

.defi-risk {
  max-width: 15rem;
  margin-top: .35rem;
  overflow: hidden;
  color: #9a3412;
  font-size: .76rem;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.defi-cell-number {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
}

.defi-score-mini {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 3.2rem;
  color: var(--ink);
}

.defi-market {
  color: var(--ink);
  font-weight: 790;
}

.defi-classification {
  color: var(--ink);
  font-weight: 760;
}

/* Insights */
.insights-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.insights-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: flex-end;
  gap: .75rem;
}

.insights-story {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(20rem, .85fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

.insights-story-main,
.insights-chart-card,
.insight-feed,
.coaching-card {
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.insights-story-main {
  padding: 1.45rem;
}

.insights-story-main h1 {
  max-width: 46rem;
  margin: .35rem 0 .55rem;
  color: var(--ink);
  font-size: clamp(1.55rem, 2.6vw, 2.25rem);
  font-weight: 830;
  line-height: 1.1;
  letter-spacing: 0;
}

.insights-story-main p {
  max-width: 44rem;
  color: #526071;
  font-size: .95rem;
  line-height: 1.55;
}

.insights-chart-card {
  min-width: 0;
  padding: 1.1rem;
}

.insight-summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .75rem;
  margin-bottom: 1rem;
}

.insight-summary-tile {
  min-width: 0;
  padding: .9rem 1rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.insight-summary-tile span,
.feed-head span,
.impact-block span,
.lesson-block span,
.coaching-footer span {
  display: block;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 780;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.insight-summary-tile strong {
  display: block;
  margin-top: .25rem;
  color: var(--ink);
  font-size: 1.18rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.insight-summary-tile.positive {
  border-top: 3px solid var(--success);
}

.insight-summary-tile.positive strong {
  color: var(--success);
}

.insight-summary-tile.negative {
  border-top: 3px solid var(--danger);
}

.insight-summary-tile.negative strong {
  color: var(--danger);
}

.insight-summary-tile.warning {
  border-top: 3px solid var(--accent);
}

.insight-summary-tile.warning strong {
  color: var(--accent);
}

.insight-feed {
  overflow: hidden;
}

.insight-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.insight-tab {
  display: flex;
  min-width: 0;
  min-height: 3.2rem;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: #526071;
  cursor: pointer;
  font-size: .86rem;
  font-weight: 760;
}

.insight-tab:last-child {
  border-right: 0;
}

.insight-tab b {
  display: inline-flex;
  min-width: 1.35rem;
  height: 1.35rem;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #e7ece9;
  color: #475467;
  font-size: .72rem;
  font-weight: 800;
}

.insight-tab:hover,
.insight-tab.active {
  background: #fff;
  color: var(--brand-strong);
}

.insight-tab.active {
  box-shadow: inset 0 -3px 0 var(--brand);
}

.insight-tab.active b {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.insight-tab-panel {
  display: none;
  padding: 1.1rem;
}

.insight-tab-panel.active {
  display: block;
}

.feed-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .8rem;
  margin-bottom: .9rem;
}

.feed-head h2 {
  margin: .12rem 0 0;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 820;
}

.feed-count {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 720;
}

.insight-card-list {
  display: grid;
  gap: .85rem;
}

.coaching-card {
  min-width: 0;
  padding: 1rem;
}

.coaching-card.danger {
  border-left: 4px solid var(--danger);
}

.coaching-card.warning {
  border-left: 4px solid var(--accent);
}

.coaching-card.neutral {
  border-left: 4px solid var(--brand);
}

.coaching-card-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: .75rem;
  align-items: start;
}

.insight-icon {
  display: inline-flex;
  width: 2.35rem;
  height: 2.35rem;
  align-items: center;
  justify-content: center;
  border-radius: .48rem;
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.coaching-card.danger .insight-icon {
  background: #fff1f0;
  color: var(--danger);
}

.coaching-card.warning .insight-icon {
  background: #fff4df;
  color: #9a5b00;
}

.insight-icon svg {
  width: 1.35rem;
  height: 1.35rem;
}

.coaching-eyebrow {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-bottom: .35rem;
}

.coaching-eyebrow span {
  display: inline-flex;
  align-items: center;
  min-height: 1.35rem;
  padding: .12rem .5rem;
  border-radius: 999px;
  background: #eef2f0;
  color: #526071;
  font-size: .7rem;
  font-weight: 780;
}

.coaching-card h3 {
  margin: 0;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 810;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.coaching-grid {
  display: grid;
  grid-template-columns: minmax(11rem, .72fr) minmax(0, 1.28fr);
  gap: .7rem;
  margin-top: .9rem;
}

.impact-block,
.lesson-block {
  min-width: 0;
  padding: .85rem;
  border: 1px solid #e8eeeb;
  border-radius: .45rem;
  background: var(--surface-soft);
}

.impact-block strong {
  display: block;
  margin-top: .2rem;
  color: var(--brand-strong);
  font-size: 1.3rem;
  font-weight: 840;
  overflow-wrap: anywhere;
}

.impact-block p,
.lesson-block p,
.coaching-detail,
.coaching-footer p,
.investment-hint {
  margin: .25rem 0 0;
  color: #526071;
  font-size: .84rem;
  line-height: 1.45;
}

.coaching-detail {
  margin-top: .85rem;
}

.evidence-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .55rem;
  margin-top: .85rem;
}

.evidence-item {
  min-width: 0;
  padding: .7rem;
  border: 1px solid #e8eeeb;
  border-radius: .45rem;
  background: #fff;
}

.evidence-item span {
  display: block;
  color: var(--ink);
  font-size: .78rem;
  font-weight: 760;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.evidence-item p {
  margin: .18rem 0 .35rem;
  color: var(--muted);
  font-size: .74rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.evidence-item strong {
  display: block;
  color: var(--ink);
  font-size: .84rem;
  font-weight: 800;
}

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

.coaching-footer > div {
  min-width: 0;
}

.investment-hint {
  color: var(--brand-strong);
  font-weight: 680;
}

/* Receipts library */
.receipts-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.receipts-review-panel {
  margin-bottom: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.receipts-quick-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: .65rem;
  margin-bottom: .9rem;
}

.receipts-filter-grid {
  display: grid;
  grid-template-columns: minmax(14rem, 1.4fr) minmax(8rem, .65fr) minmax(8rem, .65fr) minmax(8rem, .65fr) minmax(10rem, .8fr);
  gap: .75rem;
  align-items: end;
}

.receipts-filter-field,
.receipts-filter-actions {
  min-width: 0;
}

.receipts-range {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .45rem;
}

.receipts-filter-actions {
  display: flex;
  gap: .45rem;
}

.receipts-table-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.receipts-table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  min-height: 4rem;
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--line);
}

.receipts-summary {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-left: auto;
}

.receipts-summary span,
.receipt-type,
.receipt-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  font-size: .72rem;
  font-weight: 760;
  white-space: nowrap;
}

.receipts-summary span {
  min-height: 1.55rem;
  padding: .18rem .55rem;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
}

.receipts-table-scroll {
  overflow-x: auto;
}

.receipts-table td {
  vertical-align: top;
}

.receipts-table {
  white-space: normal;
}

.receipt-item-cell {
  min-width: 20rem;
  max-width: 30rem;
}

.receipt-title-line {
  display: flex;
  align-items: center;
  gap: .45rem;
  min-width: 0;
}

.receipt-type {
  min-height: 1.4rem;
  padding: .15rem .5rem;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
}

.receipt-type.invoice {
  border-color: #e4d7fb;
  background: #f1eafe;
  color: #6d28d9;
}

.receipt-type.receipt {
  border-color: #cfe8ea;
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.receipt-preview-link {
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--brand-strong);
  font-weight: 780;
  text-align: left;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.receipt-preview-link:hover {
  text-decoration: underline;
}

.receipt-file-line,
.receipt-note-line,
.receipt-deadline {
  margin-top: .28rem;
  color: var(--muted);
  font-size: .76rem;
  overflow-wrap: anywhere;
}

.receipt-note-line {
  color: #94a3b8;
}

.receipt-merchant {
  color: var(--ink);
  font-size: .86rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.receipt-status {
  min-height: 1.55rem;
  padding: .18rem .58rem;
}

.receipt-status.ok {
  background: #edfdfa;
  color: var(--success);
}

.receipt-status.warning {
  background: #fff4df;
  color: #9a5b00;
}

.receipt-actions {
  display: flex;
  justify-content: flex-end;
  gap: .4rem;
}

/* Spinner */
.spinner { width: 2rem; height: 2rem; border: 3px solid #dfe7e3; border-top-color: var(--brand); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Uncategorised highlight */
.uncategorised-row td { background: #fff8db !important; }

/* Transaction receipt picker */
.tx-receipt-layout {
  display: grid;
  grid-template-columns: minmax(230px, 0.85fr) minmax(260px, 1.15fr);
  gap: 0.75rem;
}
.tx-receipt-results {
  max-height: 26rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.tx-receipt-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: #fff;
  cursor: pointer;
  transition: border 0.15s, background 0.15s, box-shadow 0.15s;
}
.tx-receipt-row:hover,
.tx-receipt-row.selected {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.tx-receipt-row.selected {
  box-shadow: 0 0 0 2px rgba(21,94,117,.12);
}
.tx-receipt-thumb {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 0.5rem;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  font-size: 1.2rem;
}
.tx-filter-chip {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: #475467;
  border-radius: 9999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}
.tx-filter-chip:hover,
.tx-filter-chip.active {
  border-color: var(--brand);
  color: var(--brand-strong);
  background: var(--brand-soft);
}
.tx-suggested-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  background: #dff8f2;
  color: var(--success);
  padding: 0.1rem 0.45rem;
  font-size: 0.68rem;
  font-weight: 700;
  flex: 0 0 auto;
}
.tx-receipt-preview {
  min-height: 26rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  overflow: hidden;
  background: #fff;
}
.tx-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem;
  border-bottom: 1px solid var(--line);
}
.tx-preview-frame,
.tx-preview-media {
  width: 100%;
  height: 18rem;
  border: 0;
  background: var(--surface-soft);
}
.tx-preview-media {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.tx-preview-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.tx-preview-empty {
  height: 18rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--surface-soft);
}
.tx-preview-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem 0.75rem;
  padding: 0.75rem;
  border-top: 1px solid var(--line);
}
.tx-preview-details span {
  display: block;
  color: #94a3b8;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.tx-preview-details strong {
  display: block;
  color: #344054;
  font-size: 0.82rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

@media (max-width: 760px) {
  .tx-receipt-layout {
    grid-template-columns: 1fr;
  }
  .tx-receipt-results {
    max-height: 18rem;
  }
  .tx-receipt-preview {
    min-height: 0;
  }
}

@media (max-width: 980px) {
  .receipts-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .receipts-quick-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .receipts-filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .receipts-filter-search,
  .receipts-filter-actions {
    grid-column: 1 / -1;
  }

  .receipts-table-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .receipts-summary {
    margin-left: 0;
  }

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

  .tx-quick-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tx-filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tx-filter-search,
  .tx-filter-actions {
    grid-column: 1 / -1;
  }

  .tx-table-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .tx-bulk-bar,
  .tx-pagination {
    width: 100%;
    flex-wrap: wrap;
    margin-left: 0;
  }

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

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

  .investment-actions {
    justify-content: flex-start;
  }

  .investment-workbench {
    grid-template-columns: 1fr;
  }

  .investment-controls-panel {
    position: static;
  }

  .projection-grid {
    grid-template-columns: 1fr;
  }

  .defi-radar-head {
    flex-direction: column;
  }

  .defi-filters,
  .defi-top-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .plan-controls {
    justify-content: flex-start;
  }

  .plan-story,
  .plan-grid {
    grid-template-columns: 1fr;
  }

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

  .insights-controls {
    justify-content: flex-start;
  }

  .insights-story {
    grid-template-columns: 1fr;
  }

  .insight-summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .insight-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .insight-tab:nth-child(2) {
    border-right: 0;
  }

  .insight-tab:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

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

  .month-picker {
    justify-content: flex-start;
  }

  .money-story,
  .overview-grid-main {
    grid-template-columns: 1fr;
  }

  .overview-grid-health {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .app-sidebar {
    width: min(19rem, calc(100vw - 3rem));
    transform: translateX(-105%);
    transition: transform .22s ease;
  }

  .sidebar-collapse-button {
    display: none;
  }

  .nav-open .app-sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 25;
    background: rgba(15, 23, 42, .42);
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease;
  }

  .nav-open .sidebar-backdrop {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }

  .app-main {
    margin-left: 0;
  }

  .mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: .75rem;
    min-height: 4.25rem;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--line);
    background: rgba(246, 247, 244, .9);
    backdrop-filter: blur(14px);
  }

  @supports (padding: max(0px)) {
    .app-sidebar {
      padding-top: env(safe-area-inset-top);
      padding-bottom: env(safe-area-inset-bottom);
    }

    .mobile-topbar {
      min-height: calc(4.25rem + env(safe-area-inset-top));
      padding-top: calc(.75rem + env(safe-area-inset-top));
    }
  }

  .mobile-title {
    color: var(--ink);
    font-size: .95rem;
    font-weight: 800;
    line-height: 1.2;
  }

  .page-content {
    padding: 1.15rem;
  }
}

@media (max-width: 640px) {
  .tx-review-panel {
    padding: .85rem;
  }

  .tx-quick-strip,
  .tx-filter-grid,
  .recurring-summary-grid,
  .recurring-filter-strip {
    grid-template-columns: 1fr;
  }

  .recurring-header,
  .recurring-toolbar {
    flex-direction: column;
  }

  .recurring-controls,
  .recurring-sort {
    width: 100%;
    min-width: 0;
    flex-basis: auto;
  }

  .recurring-panel {
    padding: .85rem;
  }

  .recurring-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .recurring-main {
    align-items: flex-start;
    justify-content: space-between;
  }

  .recurring-amounts {
    grid-template-columns: 1fr;
  }

  .recurring-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .recurring-actions .btn {
    width: 100%;
  }

  .tx-review-chip {
    min-height: 3.35rem;
  }

  .tx-filter-actions,
  .tx-bulk-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .tx-bulk-bar .input,
  .tx-bulk-bar .btn,
  .tx-filter-actions .btn {
    width: 100%;
  }

  .tx-table-scroll {
    overflow-x: visible;
  }

  .tx-review-table {
    display: block;
    overflow: visible;
    white-space: normal;
  }

  .tx-review-table thead {
    display: none;
  }

  .tx-review-table tbody,
  .tx-review-table tr,
  .tx-review-table td {
    display: block;
    width: 100%;
  }

  .tx-review-table tr {
    position: relative;
    padding: .85rem .85rem .95rem 2.65rem;
    border-bottom: 1px solid var(--line);
  }

  .tx-review-table tr:last-child {
    border-bottom: 0;
  }

  .tx-review-table td {
    padding: .35rem 0;
    border-bottom: 0;
  }

  .tx-review-table .tx-select-col {
    position: absolute;
    inset: .95rem auto auto .85rem;
    width: auto;
    padding: 0;
  }

  .tx-review-table .tx-meta-col {
    min-width: 0;
  }

  .tx-description {
    max-width: none;
    white-space: normal;
  }

  .tx-row-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .tx-review-table td.text-right {
    text-align: left;
  }

  .plan-story,
  .plan-panel {
    padding: .9rem;
  }

  .investment-result-panel,
  .investment-controls-panel,
  .projection-story,
  .projection-chart-panel,
  .scenario-card,
  .investment-education,
  .assumption-list,
  .defi-radar-panel {
    padding: .9rem;
  }

  .investment-actions,
  .investment-actions .btn {
    width: 100%;
  }

  .investment-education {
    grid-template-columns: 1fr;
  }

  .defi-filters,
  .defi-top-grid {
    grid-template-columns: 1fr;
  }

  .defi-radar-head .btn,
  .defi-checkbox {
    width: 100%;
  }

  .projection-story strong {
    font-size: 1.65rem;
  }

  .plan-controls,
  .plan-controls .input,
  .plan-controls .btn {
    width: 100%;
  }

  .plan-story h1 {
    font-size: 1.45rem;
  }

  .plan-legend {
    align-items: flex-start;
    flex-direction: column;
    gap: .35rem;
  }

  .savings-editor > div,
  .plan-budget-row,
  .budget-edit {
    grid-template-columns: 1fr;
  }

  .commitment-row,
  .goal-row,
  .adjustment-row {
    align-items: flex-start;
    flex-direction: column;
    gap: .55rem;
  }

  .page-content {
    padding: 1rem .8rem 1.5rem;
  }

  .page-title {
    font-size: 1.35rem;
  }

  .insights-story-main,
  .insights-chart-card,
  .insight-tab-panel,
  .coaching-card {
    padding: .9rem;
  }

  .insights-story-main h1 {
    font-size: 1.45rem;
  }

  .insight-summary-strip,
  .coaching-grid,
  .evidence-grid {
    grid-template-columns: 1fr;
  }

  .insight-tab {
    min-height: 3rem;
    flex-direction: column;
    gap: .2rem;
    font-size: .78rem;
  }

  .coaching-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .coaching-footer .btn {
    width: 100%;
  }

  .money-story {
    padding: 1rem;
  }

  .story-main h1 {
    font-size: 1.55rem;
  }

  .story-metrics,
  .overview-grid-health {
    grid-template-columns: 1fr;
  }

  .health-card {
    min-height: 0;
  }

  .split-head,
  .panel-head,
  .driver-row,
  .opportunity-row,
  .action-row {
    align-items: flex-start;
  }

  .split-head,
  .driver-row,
  .opportunity-row {
    flex-direction: column;
  }

  .chart-frame {
    height: 16rem;
  }

  .card,
  .stat-card {
    padding: 1rem;
  }

  .data-table:not(.tx-review-table) {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .receipts-table {
    min-width: 62rem;
    white-space: normal;
  }

  .btn {
    min-height: 2.45rem;
  }

  #toast {
    right: .8rem !important;
    bottom: .8rem !important;
    left: .8rem;
  }
}

@media (max-width: 640px) {
  .receipts-quick-strip,
  .receipts-filter-grid,
  .receipts-range {
    grid-template-columns: 1fr;
  }

  .receipts-filter-actions,
  .receipt-actions {
    flex-wrap: wrap;
  }

  .receipts-review-panel {
    padding: .85rem;
  }

  .receipts-table-scroll {
    overflow-x: visible;
  }

  .receipts-table {
    display: block;
    min-width: 0;
    overflow: visible;
  }

  .receipts-table thead {
    display: none;
  }

  .receipts-table tbody,
  .receipts-table tr,
  .receipts-table td {
    display: block;
    width: 100%;
  }

  .receipts-table tr {
    padding: .9rem;
    border-bottom: 1px solid var(--line);
  }

  .receipts-table tr:last-child {
    border-bottom: 0;
  }

  .receipts-table td {
    padding: .35rem 0;
    border-bottom: 0;
  }

  .receipts-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: .18rem;
    color: var(--muted);
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
  }

  .receipt-item-cell {
    min-width: 0;
    max-width: none;
  }

  .receipts-table td.text-right {
    text-align: left;
  }

  .receipt-actions .btn {
    flex: 1 1 8rem;
  }
}
body.auth-locked .app-sidebar,
body.auth-locked .mobile-topbar,
body.auth-locked .sidebar-backdrop {
  display: none;
}

body.auth-locked .app-main {
  margin-left: 0;
}

body.auth-locked .page-content {
  min-height: 100vh;
  padding: 0;
}

.auth-panel {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    linear-gradient(135deg, rgba(20, 83, 45, .08), rgba(14, 116, 144, .08)),
    #f8fafc;
}

.auth-card {
  width: min(100%, 24rem);
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .12);
}

.auth-mark {
  width: 3rem;
  height: 3rem;
  display: grid;
  place-items: center;
  margin-bottom: 1rem;
  border-radius: 8px;
  color: #0f766e;
  background: #ccfbf1;
}

.auth-mark svg {
  width: 1.7rem;
  height: 1.7rem;
}

.auth-card h1 {
  margin: 0;
  color: var(--ink);
  font-size: 1.45rem;
  font-weight: 850;
  letter-spacing: 0;
}

.auth-card p {
  margin: .35rem 0 1.25rem;
  color: var(--muted);
}

.auth-form {
  display: grid;
  gap: .85rem;
}

.auth-form label {
  display: grid;
  gap: .35rem;
  color: var(--ink);
  font-size: .85rem;
  font-weight: 750;
}

.auth-form input {
  width: 100%;
  min-height: 2.7rem;
  padding: .7rem .8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.auth-form input:focus {
  outline: 2px solid rgba(20, 184, 166, .25);
  border-color: #14b8a6;
}

.auth-form button {
  min-height: 2.8rem;
  border: 0;
  border-radius: 8px;
  background: #0f766e;
  color: #fff;
  font-weight: 850;
}

.auth-form button:disabled {
  opacity: .65;
}

.auth-error {
  color: #b91c1c;
  font-size: .85rem;
  font-weight: 700;
}
