:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1e1f1d;
  background: #f4f1eb;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input, select { font: inherit; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 32px 20px 64px; }
header { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 28px; }
h1 { margin: 0; font-size: 38px; letter-spacing: -0.03em; }
h2 { margin: 0; }
.eyebrow { color: #77736b; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 4px; }
.muted { color: #78746d; }
.grid { display: grid; grid-template-columns: repeat(12, minmax(0,1fr)); gap: 14px; }
.card { background: #fff; border: 1px solid #e5dfd5; border-radius: 20px; padding: 20px; box-shadow: 0 3px 18px rgba(49,40,28,.05); }
.metric { grid-column: span 4; }
.account { grid-column: span 4; }
.wide { grid-column: span 7; }
.side { grid-column: span 5; }
.full { grid-column: 1 / -1; }
.label { font-size: 12px; color: #807b73; text-transform: uppercase; letter-spacing: .08em; }
.big { margin-top: 8px; font-size: 32px; font-weight: 720; letter-spacing: -0.03em; }
.metric-breakdown { display: grid; gap: 4px; margin-top: 10px; }
.metric-breakdown-row { display: flex; justify-content: space-between; gap: 12px; color: #7d776f; font-size: 11px; font-variant-numeric: tabular-nums; }
.metric-breakdown-row span:last-child { color: #4f6657; font-weight: 650; }
.tiny { font-size: 12px; color: #8a857d; margin-top: 8px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 8px; border-bottom: 1px solid #eee8df; font-size: 14px; }
th { color: #827d75; font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.expense { color: #9f4238; }
.income { color: #2f7451; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; }
.good { background: #3f8a62; }
.bad { background: #c36256; }
.empty { padding: 24px 0; color: #8a857d; }
.status { display: inline-flex; gap: 8px; align-items: center; color: #77736b; font-size: 13px; }
.header-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.secondary-button, .ghost-button, .connect-form button { border: 0; border-radius: 12px; padding: 10px 14px; cursor: pointer; font-weight: 650; }
.secondary-button, .connect-form button[type="submit"] { background: #22211f; color: #fff; }
.ghost-button { background: #eee9e1; color: #34312d; }
button:disabled { opacity: .55; cursor: default; }
.connect-panel { margin-bottom: 14px; display: grid; grid-template-columns: 1.4fr 1fr; gap: 28px; align-items: end; }
.connect-panel h2 { margin-top: 5px; font-size: 24px; }
.connect-panel p { margin: 8px 0 0; line-height: 1.5; }
.connect-form label { display: block; font-size: 13px; color: #6e6962; margin-bottom: 6px; }
.connect-form select { width: 100%; border: 1px solid #dcd5ca; border-radius: 12px; padding: 12px 13px; background: white; }
.connect-actions { display: flex; gap: 8px; margin-top: 12px; }

.transaction-card { padding-bottom: 16px; }
.transaction-heading { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 16px; }
.transaction-heading h2 { margin-top: 4px; font-size: 24px; letter-spacing: -.02em; }
.filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; padding: 14px; margin: 0 -4px 10px; background: #f8f5f0; border: 1px solid #eee7dc; border-radius: 16px; }
.filters label, .custom-dates label { display: grid; gap: 5px; font-size: 11px; color: #777169; text-transform: uppercase; letter-spacing: .06em; }
.filters select, .filters input, .custom-dates input { width: 100%; min-width: 0; border: 1px solid #ddd5ca; border-radius: 10px; padding: 9px 10px; background: #fff; color: #282521; text-transform: none; letter-spacing: normal; outline: none; }
.filters select:focus, .filters input:focus, .custom-dates input:focus { border-color: #9c9488; box-shadow: 0 0 0 3px rgba(110,102,93,.07); }
.search-filter { grid-column: span 2; }
.custom-dates { display: flex; gap: 10px; align-items: end; margin: 8px 0 12px; }
.custom-dates label { width: min(220px, 45%); }
.review-options { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 10px 2px 12px; font-size: 12px; }
.checkbox-label { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; color: #4b4741; }
.checkbox-label input { width: 15px; height: 15px; }
.transaction-scroll { max-height: 560px; overflow: auto; border: 1px solid #eee7dc; border-radius: 14px; position: relative; }
.transaction-table { min-width: 880px; }
.transaction-table thead th { position: sticky; top: 0; z-index: 2; background: #fff; box-shadow: inset 0 -1px 0 #eee8df; }
.transaction-table td { vertical-align: middle; }
.transaction-table tr.needs-review { background: #fff9ed; }
.transaction-table tr:hover { background: #faf8f4; }
.merchant-main { font-weight: 610; color: #2b2824; max-width: 380px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.merchant-detail { max-width: 380px; margin-top: 2px; color: #8a847c; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.category-select { width: 170px; border: 1px solid #ddd5ca; border-radius: 9px; padding: 7px 8px; background: white; }
.category-select.needs-review { border-color: #d4a13d; background: #fffaf0; }
.source-pill { display: inline-block; padding: 4px 7px; border-radius: 999px; font-size: 10px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; background: #f0ece6; color: #777067; white-space: nowrap; }
.source-pill.manual { background: #e8f0ff; color: #46638f; }
.source-pill.rule { background: #e9f4ed; color: #426b50; }
.source-pill.email { background: #efeafd; color: #65558a; }
.source-pill.unclassified { background: #fff1d5; color: #8b6420; }
.tx-loading { padding: 16px; text-align: center; color: #827c73; font-size: 13px; }
.tx-load-more { display: block; margin: 12px auto 0; }
.saving { opacity: .55; pointer-events: none; }

.login-backdrop { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(244,241,235,.86); backdrop-filter: blur(8px); z-index: 10; }
.login { width: min(420px, calc(100vw - 32px)); background: white; border: 1px solid #e3ddd2; border-radius: 24px; padding: 28px; box-shadow: 0 18px 70px rgba(42,34,25,.16); }
.login h2 { margin: 0 0 6px; font-size: 28px; }
.login p { margin: 0 0 20px; color: #79746c; }
.login label { display: block; font-size: 13px; color: #6e6962; margin: 12px 0 6px; }
.login input { width: 100%; border: 1px solid #dcd5ca; border-radius: 12px; padding: 12px 13px; outline: none; }
.login input:focus { border-color: #888177; box-shadow: 0 0 0 3px rgba(110,102,93,.08); }
.login button { width: 100%; border: 0; border-radius: 12px; padding: 12px 14px; margin-top: 16px; background: #22211f; color: white; cursor: pointer; font-weight: 650; }
.error { color: #a1483f; min-height: 20px; font-size: 13px; margin-top: 10px; }
.hidden { display: none !important; }
.legal { max-width: 760px; margin: 48px auto; padding: 0 20px 64px; line-height: 1.65; }
.legal h1 { margin-bottom: 16px; }
.legal h2 { margin-top: 30px; }
.legal a { color: inherit; }
@media (max-width: 900px) {
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search-filter { grid-column: 1 / -1; }
}
@media (max-width: 800px) {
  header { align-items: flex-start; flex-direction: column; }
  .header-actions { justify-content: flex-start; }
  .metric, .account, .wide, .side { grid-column: 1 / -1; }
  .connect-panel { grid-template-columns: 1fr; }
  .wrap { padding-top: 24px; }
  .transaction-scroll { max-height: 520px; }
}
@media (max-width: 560px) {
  .filters { grid-template-columns: 1fr; }
  .search-filter { grid-column: auto; }
  .custom-dates { flex-direction: column; align-items: stretch; }
  .custom-dates label { width: 100%; }
  .transaction-heading { align-items: flex-start; flex-direction: column; }
}

.data-connection-row { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.data-connection-row h2 { margin: 4px 0 7px; font-size: 22px; letter-spacing: -.02em; }
.data-connection-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 700px) {
  .data-connection-row { align-items: flex-start; flex-direction: column; }
  .data-connection-actions { justify-content: flex-start; }
}

.merchant-evidence { margin-top: 7px; padding: 7px 9px; border-radius: 10px; background: #f3f7f3; border: 1px solid #dfeadf; max-width: 380px; }
.merchant-evidence.suggested { background: #fff9ed; border-color: #ead9b5; }
.merchant-evidence-heading { font-size: 9px; font-weight: 750; text-transform: uppercase; letter-spacing: .07em; color: #5a7561; }
.merchant-evidence.suggested .merchant-evidence-heading { color: #8c6a2c; }
.merchant-evidence-merchant { margin-top: 2px; font-size: 12px; font-weight: 650; color: #35312d; }
.merchant-evidence-items { margin-top: 2px; font-size: 10px; color: #777169; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.merchant-evidence-actions { display: flex; gap: 6px; margin-top: 7px; flex-wrap: wrap; }
.merchant-evidence-button {
  border: 1px solid #d9d1c5;
  border-radius: 8px;
  padding: 5px 8px;
  background: #fff;
  color: #4b4640;
  font-size: 10px;
  font-weight: 650;
  cursor: pointer;
}
.merchant-evidence-button.confirm { border-color: #bfd8c4; color: #426b50; }
.merchant-evidence-button.reject { color: #756b60; }
.merchant-evidence-button:disabled { opacity: .55; cursor: default; }


/* Accounts & connections hub */
.connections-hub { padding: 0; overflow: hidden; }
.connections-hub-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.connections-hub-summary::-webkit-details-marker { display: none; }
.connections-hub-summary::marker { content: ''; }
.connections-hub-summary h2 { margin: 0; font-size: 24px; letter-spacing: -.02em; }
.connections-hub-chevron { color: #837d74; font-size: 20px; line-height: 1; transition: transform .18s ease; }
.connections-hub[open] .connections-hub-chevron { transform: rotate(180deg); }

.connections-hub-body {
  display: grid;
  gap: 14px;
  padding: 16px 18px 18px;
  border-top: 1px solid #eee8df;
  background: #fbfaf7;
}

/* Three visual sections inside the one collapsible parent. None are collapsible. */
.connection-section {
  padding: 16px 18px;
  border: 1px solid #e6dfd5;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(49,40,28,.035);
}
.connection-section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 12px;
}
.connection-section-heading h3 {
  margin: 0 0 3px;
  font-size: 17px;
  font-weight: 720;
  letter-spacing: -.012em;
}
.connection-section-heading .muted { font-size: 12px; }
.connection-section-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.connection-section-actions button,
.gmail-connection-actions button {
  padding: 8px 11px;
  border-radius: 10px;
  font-size: 12px;
}

/* Accounts remain cards inside the Accounts section, with no extra heading/details layer. */
.connections-account-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}
.connections-account-grid .account {
  grid-column: auto;
  min-width: 0;
  padding: 14px;
  border: 1px solid #ece6dd;
  border-radius: 13px;
  background: #fbfaf7;
  box-shadow: none;
}
.connections-account-grid .account .big { margin-top: 7px; font-size: 27px; }
.connections-account-grid .account .tiny { margin-top: 5px; }

/* Bank connection list is contained in its own section. */
#bank-connections-group table { margin-top: 2px; }
#bank-connections-group th,
#bank-connections-group td { padding-left: 0; padding-right: 12px; }
#bank-connections-group th:last-child,
#bank-connections-group td:last-child { padding-right: 0; }
#bank-connections-group tbody tr:last-child td { border-bottom: 0; }

.connection-inline-panel {
  margin: 8px 0 12px;
  padding: 14px;
  border: 1px solid #ece6dd;
  border-radius: 12px;
  background: #fbfaf7;
  box-shadow: none;
}
.connection-inline-panel h3 { margin: 0 0 4px; font-size: 16px; }

/* Gmail account rows live inside the Gmail section, without their own card shell. */
.gmail-connections-list { display: grid; gap: 0; }
.gmail-empty { padding: 9px 0 3px; }
.gmail-connection-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 11px 0 5px;
  border: 0;
  background: transparent;
}
.gmail-connection-row + .gmail-connection-row { border-top: 1px solid #eee8df; padding-top: 13px; }
.gmail-connection-main { min-width: 0; flex: 1; }
.gmail-connection-title-row { display: flex; align-items: center; min-width: 0; }
.gmail-connection-title-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}
.gmail-connection-meta { margin-top: 3px; }
.gmail-connection-progress { margin-top: 3px; color: #6f6a63; }
.gmail-connection-error { margin-top: 5px; }
.gmail-connection-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex-shrink: 0;
}

@media (max-width: 800px) {
  .connections-account-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .connection-section-heading,
  .gmail-connection-row {
    align-items: flex-start;
    flex-direction: column;
  }
  .connection-section-actions,
  .gmail-connection-actions { justify-content: flex-start; }
  .connection-inline-panel { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .connections-account-grid { grid-template-columns: 1fr; }
}
