/* Track B — shared header chrome + Connected Accounts polish (CSS/HTML companion) */

/* —— Sitewide header: H1 left; sync · Account · Score one row —— */
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.topbar-title-row {
  display: block;
}

.topbar-title-row h1 {
  margin: 6px 0 0;
  max-width: 22ch;
}

.top-actions-shell {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
  margin-top: 2px;
}

#sessionChip,
#premiumStatus,
#styleChooser,
#openRulesFromTransactions,
.top-actions-shell .session-chip,
.top-actions-shell .style-button,
.top-actions-shell .premium-status {
  display: none !important;
}

.top-actions-shell .sync-status-button,
.top-actions-shell .auth-button,
.top-actions-shell .score-pill {
  min-height: 44px;
  flex-shrink: 0;
  opacity: 1;
}

.top-actions-shell .score-pill {
  padding: 8px 12px;
}

.top-actions-shell .score-pill > span {
  font-size: 18px;
}

.auth-button {
  position: relative;
}

.auth-premium-mark {
  position: absolute;
  top: -4px;
  right: -4px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--card, #fff);
  background: linear-gradient(145deg, #f4c84a, #e6a800);
  color: #4b3300;
  font-size: 10px;
  line-height: 1;
  font-weight: 900;
  pointer-events: none;
}

.auth-premium-mark[hidden] {
  display: none !important;
}

.page-actions {
  width: 100%;
  margin-top: 12px;
}

.page-action-set[hidden] {
  display: none !important;
}

/* Banks page: one action row — Refresh + Connect only */
body[data-page="banks"] .bank-page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 10px;
  width: 100%;
}

body[data-page="banks"] .bank-page-actions .refresh-banks-button,
body[data-page="banks"] .bank-page-actions .bank-connect-primary {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  font: 800 14px/1 "DM Sans", sans-serif;
  cursor: pointer;
}

body[data-page="banks"] .bank-page-actions .refresh-banks-button {
  border: 1px solid var(--line, #dbe2ef);
  background: transparent;
  color: var(--ink, #17213b);
  box-shadow: none;
}

body[data-page="banks"] .bank-page-actions .refresh-banks-button:hover:not(:disabled) {
  border-color: #9fb4f1;
  background: rgba(255, 255, 255, .85);
}

body[data-page="banks"] .bank-page-actions .refresh-banks-button[hidden] {
  display: none !important;
}

body[data-page="banks"] .bank-page-actions .refresh-banks-button:disabled:not([hidden]) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: .55;
  cursor: not-allowed;
  border-color: var(--line, #dbe2ef);
  background: transparent;
  color: var(--muted, #66708a);
}

body[data-page="banks"] .bank-page-actions .bank-refresh-hint {
  flex: 1 1 100%;
  margin: 2px 0 0;
  color: var(--muted, #66708a);
  font: 500 13px/1.45 "DM Sans", sans-serif;
  max-width: 42rem;
}

body[data-page="banks"] .bank-page-actions .bank-refresh-hint[hidden] {
  display: none !important;
}

body[data-page="banks"] .bank-page-actions .bank-connect-primary {
  flex: 1 1 200px;
  max-width: 320px;
  border: 0;
}

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .top-actions-shell {
    width: 100%;
    justify-content: flex-end;
    margin-top: 0;
  }

  body[data-page="banks"] .bank-page-actions .bank-connect-primary {
    flex: 1 1 100%;
    max-width: none;
  }

  body[data-page="banks"] .bank-page-actions .refresh-banks-button {
    flex: 1 1 calc(50% - 5px);
  }
}

/* Restore score in header on dashboard/calendar (override legacy hide) */
body[data-page="dashboard"] .top-actions-shell .score-pill,
body[data-page="calendar"] .top-actions-shell .score-pill {
  display: flex !important;
}

/* —— Household Cash hero hierarchy (minimal #52 item-4; full pass stays on Track A) —— */
.household-total-card.primary {
  color: #fff;
}

.account-summary .household-total-card.primary .household-cash-current,
.household-total-card.primary .household-cash-current {
  margin-top: 4px;
  font: 800 clamp(26px, 4vw, 32px) Manrope, sans-serif;
  color: #fff !important;
  letter-spacing: -.02em;
}

.household-total-card.primary .household-cash-forecast {
  display: block;
  margin-top: 8px;
  font: 600 13px/1.45 "DM Sans", sans-serif;
  color: rgba(255, 255, 255, .88);
  opacity: 1;
}

.household-total-card.primary .trust-chip-slot {
  margin-top: 10px;
}

.household-total-card:not(.primary) {
  min-width: 0;
  overflow: hidden;
}

.household-total-card:not(.primary) small,
.household-total-card:not(.primary) span {
  overflow-wrap: anywhere;
}

.household-total-card.household-total-card--quiet {
  opacity: .55;
  border-style: dashed;
}

.household-total-grid {
  align-items: stretch;
}

@media (max-width: 900px) and (min-width: 721px) {
  .household-total-grid {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr);
  }

  .household-total-card:not(.primary) {
    padding: 14px;
  }

  .household-total-card:not(.primary) .trust-chip-slot {
    max-width: 100%;
  }

  .household-total-card:not(.primary) .trust-chip {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* Forecast strip: demote when no real connections */
body[data-banks-connected="false"] #accountForecastStrip {
  display: none !important;
}

body[data-banks-connected="false"] .household-total-card--quiet {
  display: none;
}

/* Empty Connected Accounts */
.banks-empty-panel {
  display: grid;
  gap: 12px;
  margin: 8px 0 20px;
  padding: 22px 20px;
  border: 1px dashed var(--line, #dbe2ef);
  border-radius: 16px;
  background: color-mix(in srgb, var(--card, #fff) 92%, var(--paper, #f5f7fd));
  text-align: center;
}

.banks-empty-panel[hidden] {
  display: none !important;
}

.banks-empty-panel strong {
  font: 800 20px Manrope, sans-serif;
}

.banks-empty-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  max-width: 520px;
  justify-self: center;
}

.banks-empty-panel .primary {
  justify-self: center;
  min-height: 44px;
  min-width: min(100%, 240px);
  width: auto;
  padding: 0 20px;
  margin-top: 4px;
}

#bankDataCard .sync-connect-bank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 14px;
  min-height: 44px;
  width: 100%;
  max-width: 280px;
  padding: 0 16px;
  border-radius: 12px;
  font: 800 14px/1 "DM Sans", sans-serif;
  cursor: pointer;
}

#bankDataCard .sync-connect-bank.secondary {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
}

.account-menu {
  position: fixed;
  z-index: 90;
  top: 64px;
  right: 12px;
  width: min(280px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  margin: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 18px 48px rgba(16, 26, 55, .18);
  display: grid;
  gap: 2px;
}

.account-menu[hidden] {
  display: none !important;
}

.account-menu-identity {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
  padding: 8px 8px 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.account-menu-identity strong,
.account-menu-identity small {
  display: block;
  overflow-wrap: anywhere;
}

.account-menu-identity small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.account-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 42px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font: 700 14px/1.2 "DM Sans", sans-serif;
  text-align: left;
  cursor: pointer;
}

.account-menu-item[hidden] {
  display: none !important;
}

.account-menu-item:hover,
.account-menu-item:focus-visible {
  background: color-mix(in srgb, var(--ink) 8%, transparent);
  outline: none;
}

.account-menu-rule {
  height: 1px;
  margin: 4px 8px;
  border: 0;
  background: var(--line);
}

.account-menu-invite-marks {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.account-menu-dot,
.auth-invite-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e23b4a;
}

.auth-invite-dot {
  position: absolute;
  top: 6px;
  left: 28px;
  width: 10px;
  height: 10px;
  border: 2px solid var(--card, #fff);
  pointer-events: none;
}

.auth-invite-dot[hidden] {
  display: none !important;
}

.account-menu-badge {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 99px;
  background: #e23b4a;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

@media (max-width: 390px) {
  .account-menu {
    right: 12px;
    left: auto;
    width: min(280px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
  }
}

body[data-banks-empty="true"] .bank-page-toolbar,
body[data-banks-empty="true"] #accountSummary,
body[data-banks-empty="true"] #accountList {
  display: none !important;
}

.profile-appearance-row {
  display: flex;
  justify-content: flex-start;
  margin-top: 4px;
}

.profile-appearance-row .appearance-button {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}
