:root {
    color-scheme: light;
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-muted: #edf4f7;
    --text: #10202b;
    --muted: #607080;
    --line: #d7e2ea;
    --primary: #027d7f;
    --primary-dark: #005c61;
    --accent: #d99a16;
    --cyan: #1fa7ff;
    --magenta: #e23b7d;
    --bank-teal: #38d1c9;
    --good: #12835d;
    --warning: #b7791f;
    --danger: #c82645;
    --ink: #071421;
    --shadow: 0 14px 34px rgba(16, 32, 43, 0.11);
    --glow: 0 18px 46px rgba(2, 125, 127, 0.20);
}

.theme-dark {
    color-scheme: dark;
    --bg: #071421;
    --surface: #0d1b2b;
    --surface-muted: #13283a;
    --text: #f7fbff;
    --muted: #a8b7c4;
    --line: #23394c;
    --primary: #38d1c9;
    --primary-dark: #1fa9a5;
    --accent: #f4b63c;
    --cyan: #35b8ff;
    --magenta: #ff4c8d;
    --bank-teal: #38d1c9;
    --good: #63e6ae;
    --warning: #f1bc5e;
    --danger: #ff667d;
    --ink: #05101a;
    --shadow: 0 16px 42px rgba(0, 0, 0, 0.34);
    --glow: 0 20px 56px rgba(53, 184, 255, 0.18);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background:
        linear-gradient(135deg, rgba(31, 167, 255, 0.10), transparent 28%),
        linear-gradient(315deg, rgba(226, 59, 125, 0.08), transparent 28%),
        var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

a {
    color: var(--primary);
}

.topbar {
    background: rgba(7, 20, 33, 0.94);
    border-bottom: 1px solid rgba(53, 184, 255, 0.16);
    box-shadow: 0 16px 38px rgba(7, 20, 33, 0.22);
    backdrop-filter: blur(16px);
    position: sticky;
    top: 0;
    z-index: 5;
}

.topbar-inner,
.page {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
}

.topbar-inner {
    min-height: 78px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #ffffff;
    text-decoration: none;
    min-width: 260px;
}

.brand-logo {
    display: block;
    height: 48px;
    object-fit: contain;
    width: 48px;
}

.brand-copy {
    display: flex;
    flex-direction: column;
}

.brand strong {
    color: #38d1c9;
    font-size: 22px;
    line-height: 1.1;
}

.brand span {
    color: #aab6c2;
    font-size: 13px;
}

.nav {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
    min-width: 0;
}

.nav-link,
.nav-dropdown summary {
    border: 1px solid transparent;
    border-radius: 6px;
    color: #dbe4eb;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    min-height: 40px;
    padding: 9px 11px;
    text-decoration: none;
    white-space: nowrap;
}

.nav-link:hover,
.nav-dropdown:hover summary,
.nav-dropdown[open] summary {
    background: rgba(56, 209, 201, 0.12);
    border-color: rgba(56, 209, 201, 0.22);
    color: #ffffff;
}

.nav-dropdown {
    position: relative;
}

.nav-dropdown summary {
    align-items: center;
    display: flex;
    gap: 7px;
    list-style: none;
}

.nav-dropdown summary::-webkit-details-marker {
    display: none;
}

.nav-dropdown summary::after {
    border: solid currentColor;
    border-width: 0 2px 2px 0;
    content: "";
    display: inline-block;
    height: 6px;
    margin-top: -3px;
    transform: rotate(45deg);
    width: 6px;
}

.nav-dropdown[open] summary::after {
    margin-top: 3px;
    transform: rotate(-135deg);
}

.nav-dropdown-menu {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
    display: grid;
    gap: 4px;
    min-width: 220px;
    padding: 8px;
    position: absolute;
    right: 0;
    top: 100%;
    z-index: 30;
}

.nav .nav-dropdown-menu {
    left: 0;
    right: auto;
}

.nav-dropdown-menu a {
    border-radius: 6px;
    color: var(--text);
    font-size: 14px;
    font-weight: 800;
    padding: 10px 11px;
    text-decoration: none;
    white-space: nowrap;
}

.nav-dropdown-menu a:hover,
.nav-dropdown-menu a:focus {
    background: #339966;
    color: #ffffff;
}

.account-menu {
    align-items: center;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    min-width: 190px;
}

.account-avatar {
    align-items: center;
    background: rgba(67, 166, 168, 0.18);
    border: 1px solid rgba(67, 166, 168, 0.45);
    border-radius: 999px;
    color: #ffffff;
    display: inline-flex;
    font-size: 14px;
    font-weight: 900;
    height: 34px;
    justify-content: center;
    width: 34px;
}

.account-name {
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-dropdown summary {
    color: #ffffff;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.auth-nav {
    margin-left: auto;
}

.page {
    padding: 28px 0 48px;
}

.auth-layout {
    min-height: calc(100vh - 68px);
    display: grid;
    place-items: center;
    padding: 32px 16px;
}

.auth-panel {
    width: min(440px, 100%);
}

.auth-install-button {
    margin: 8px 0 18px;
    width: 100%;
}

.pwa-install-button {
    color: #f4c542;
}

.pwa-install-button:hover,
.pwa-install-button:focus,
.pwa-install-button:active {
    background: var(--primary);
    box-shadow: none;
    color: #f4c542;
    transform: none;
}

.is-installed-app .pwa-install-button {
    display: none !important;
}

@media (display-mode: standalone), (display-mode: fullscreen), (display-mode: minimal-ui), (display-mode: window-controls-overlay) {
    .pwa-install-button {
        display: none !important;
    }
}

.invite-link-field {
    margin-top: 16px;
}

.plaid-mode-status {
    display: flex;
    gap: 10px;
    justify-content: space-between;
}

.plaid-mode-status span {
    color: var(--muted);
    font-weight: 700;
}

.share-list {
    border-top: 1px solid var(--line);
    display: grid;
    gap: 6px;
    margin-top: 16px;
    padding-top: 14px;
}

.share-list span {
    color: var(--muted);
    font-size: 14px;
}

.panel,
.stat,
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.panel {
    padding: 22px;
}

.panel,
.stat,
.table-wrap,
.wide-stat,
.empty {
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.panel:hover,
.stat:hover,
.table-wrap:hover,
.wide-stat:hover,
.empty:hover {
    border-color: rgba(2, 125, 127, 0.38);
    box-shadow: var(--glow);
    transform: translateY(-1px);
}

.bank-account-row {
    border-left: 5px solid transparent;
    transition: background-color 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.bank-account-personal {
    background: linear-gradient(90deg, rgba(226, 59, 125, 0.13), rgba(31, 167, 255, 0.05));
    border-left-color: var(--magenta);
}

.bank-account-personal td:first-child {
    box-shadow: inset 5px 0 0 var(--magenta);
}

.bank-account-personal .pill {
    background: rgba(226, 59, 125, 0.14);
    border-color: rgba(226, 59, 125, 0.32);
    color: var(--magenta);
}

.bank-account-unmapped {
    background: linear-gradient(90deg, rgba(96, 112, 128, 0.10), transparent);
}

.theme-dark .bank-account-personal {
    background: linear-gradient(90deg, rgba(255, 76, 141, 0.20), rgba(53, 184, 255, 0.08));
}

.theme-dark .bank-account-personal .pill {
    background: rgba(255, 76, 141, 0.18);
    border-color: rgba(255, 76, 141, 0.42);
}

.panel h1,
.panel h2,
.page-title h1 {
    margin: 0 0 8px;
    line-height: 1.15;
}

.panel p,
.page-title p {
    margin: 0 0 18px;
    color: var(--muted);
}

.page-title {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 20px;
}

.dashboard-title h1 {
    font-size: 34px;
}

.dashboard-hero {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    gap: 16px;
    margin-bottom: 18px;
}

.hero-balance-card,
.hero-insight-card {
    background:
        linear-gradient(145deg, rgba(31, 167, 255, 0.22), transparent 46%),
        linear-gradient(315deg, rgba(226, 59, 125, 0.18), transparent 48%),
        var(--ink);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    box-shadow: 0 24px 60px rgba(7, 20, 33, 0.28);
    color: #ffffff;
    overflow: hidden;
    padding: 24px;
    position: relative;
}

.theme-light .hero-balance-card,
.theme-light .hero-insight-card {
    color: #ffffff;
}

.hero-balance-card::after {
    border: 18px solid rgba(56, 209, 201, 0.16);
    border-left-color: rgba(244, 182, 60, 0.95);
    border-radius: 999px;
    content: "";
    height: 160px;
    position: absolute;
    right: -48px;
    top: -42px;
    transform: rotate(28deg);
    width: 160px;
}

.eyebrow {
    color: rgba(255, 255, 255, 0.72);
    display: block;
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
}

.hero-balance-card strong {
    color: #f4c542;
    display: block;
    font-size: 46px;
    line-height: 1;
    margin: 13px 0 18px;
    position: relative;
    z-index: 1;
}

.hero-balance-meta {
    display: grid;
    gap: 8px;
    margin-bottom: 18px;
    position: relative;
    z-index: 1;
}

.hero-balance-meta span,
.earmark-list em {
    align-items: center;
    display: flex;
    font-size: 14px;
    font-style: normal;
    font-weight: 800;
    gap: 8px;
}

.good-dot::before,
.danger-dot::before {
    border-radius: 999px;
    content: "";
    height: 10px;
    width: 10px;
}

.good-dot::before {
    background: var(--good);
}

.danger-dot::before {
    background: var(--danger);
}

.earmark-list {
    border-top: 1px solid rgba(255, 255, 255, 0.14);
    display: grid;
    gap: 7px;
    padding-top: 14px;
    position: relative;
    z-index: 1;
}

.earmark-list em {
    color: #ff8797;
}

.hero-insight-card .section-head h2,
.hero-insight-card .section-head p {
    color: #ffffff;
}

.hero-insight-card .section-head p {
    color: rgba(255, 255, 255, 0.68);
}

.insight-bars {
    display: grid;
    gap: 18px;
}

.insight-row {
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(0, 1fr) auto;
}

.insight-row span {
    color: rgba(255, 255, 255, 0.74);
    font-weight: 800;
}

.insight-row strong {
    color: #ffffff;
}

.insight-row i {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    display: block;
    grid-column: 1 / -1;
    height: 12px;
    overflow: hidden;
}

.insight-row b {
    background: linear-gradient(90deg, var(--primary), var(--cyan), var(--magenta));
    border-radius: inherit;
    display: block;
    height: 100%;
    min-width: 8px;
}

.stats-grid,
.estimated-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.estimated-stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.current-month-available-stat {
    justify-self: stretch;
    width: 100%;
}

.current-month-available-stat::before {
    background: var(--warning);
}

.current-month-available-stat > span {
    color: var(--warning);
}

.current-month-available-stat strong {
    font-size: 30px;
    font-weight: 900;
}

.planning-stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 20px;
    margin-bottom: 20px;
}

.transaction-stats-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    margin-top: 0;
}

.transaction-insight-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.9fr);
    margin-bottom: 20px;
}

.transaction-insight-panel {
    min-width: 0;
}

.category-bars,
.snapshot-list {
    display: grid;
    gap: 13px;
}

.category-bar {
    display: grid;
    gap: 8px;
}

.category-bar div,
.snapshot-list div {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
}

.category-bar span,
.snapshot-list span {
    color: var(--muted);
    font-weight: 800;
}

.category-bar strong,
.snapshot-list strong {
    color: var(--text);
    text-align: right;
}

.category-bar i {
    background: var(--surface-muted);
    border-radius: 999px;
    display: block;
    height: 10px;
    overflow: hidden;
}

.category-bar b {
    background: linear-gradient(90deg, #38d1c9, #00ace6);
    border-radius: inherit;
    display: block;
    height: 100%;
    min-width: 6px;
}

.transaction-filter-panel {
    background: var(--surface-strong);
    border: 1px solid var(--line);
    border-radius: 8px;
    margin: 12px 0 18px;
    padding: 16px;
}

.collapsible-panel {
    margin-bottom: 18px;
}

.collapsible-panel > summary {
    cursor: pointer;
    display: block;
    list-style: none;
}

.collapsible-panel > summary::-webkit-details-marker {
    display: none;
}

.collapsible-panel > summary .section-head {
    margin-bottom: 0;
}

.collapsible-panel > summary > span:first-child {
    display: grid;
    gap: 3px;
}

.collapsible-panel > summary strong {
    color: var(--text);
    font-size: 18px;
}

.collapsible-panel > summary small {
    color: var(--muted);
    font-size: 14px;
}

.transaction-filter-details {
    background: var(--surface-muted);
    border: 1px solid var(--line);
    border-radius: 8px;
    margin: 4px 0 18px;
    padding: 14px;
}

.transaction-filter-details > summary {
    align-items: center;
    display: flex;
    gap: 14px;
    justify-content: space-between;
}

.collapsible-body {
    border-top: 1px solid var(--line);
    margin-top: 16px;
    padding-top: 16px;
}

.hide-label,
.collapsible-panel[open] .show-label {
    display: none;
}

.collapsible-panel[open] .hide-label {
    display: inline;
}

.transaction-card-list {
    display: grid;
    gap: 12px;
}

.transaction-queue-head {
    align-items: center;
    display: flex;
    gap: 14px;
    justify-content: space-between;
    margin-bottom: 12px;
}

.transaction-queue-head h3 {
    font-size: 18px;
    margin: 0 0 4px;
}

.transaction-queue-head p {
    margin: 0;
}

.categorized-transactions-panel {
    background: var(--surface-muted);
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-top: 16px;
    padding: 14px;
}

.categorized-transactions-panel > summary {
    align-items: center;
    display: flex;
    gap: 14px;
    justify-content: space-between;
}

.categorized-transactions-panel > summary small {
    color: var(--muted);
    display: block;
    margin-top: 3px;
}

.compact-empty {
    margin-bottom: 0;
}

.transaction-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 5px solid var(--danger);
    border-radius: 8px;
    box-shadow: var(--shadow);
    display: grid;
    gap: 12px;
    padding: 16px;
}

.transaction-card.income {
    border-left-color: #339966;
}

.transaction-card.ignored,
.ignored-row {
    opacity: 0.72;
}

.transaction-card.ignored {
    border-left-color: var(--muted);
}

.transaction-highlight {
    animation: transactionPulse 2.1s ease;
    outline: 3px solid rgba(244, 197, 66, 0.85);
    outline-offset: 3px;
}

@keyframes transactionPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(244, 197, 66, 0.55), var(--shadow);
    }
    70% {
        box-shadow: 0 0 0 14px rgba(244, 197, 66, 0), var(--shadow);
    }
    100% {
        box-shadow: var(--shadow);
    }
}

.ignored-pill {
    background: rgba(148, 163, 184, 0.18);
    color: var(--muted);
}

.transaction-main,
.transaction-meta {
    align-items: flex-start;
    display: flex;
    gap: 12px;
    justify-content: space-between;
}

.transaction-main div {
    display: grid;
    gap: 5px;
    min-width: 0;
}

.transaction-main strong:first-child {
    color: var(--text);
    font-size: 17px;
}

.transaction-main span,
.transaction-meta span,
.transaction-card p {
    color: var(--muted);
    margin: 0;
}

.transaction-main > strong {
    font-size: 19px;
    white-space: nowrap;
}

.transaction-meta {
    align-items: center;
}

.transaction-table-wrap {
    display: none;
    margin-top: 0;
}

.transaction-table-wrap table {
    min-width: 1320px;
    table-layout: fixed;
}

.transaction-table-wrap th:nth-child(1),
.transaction-table-wrap td:nth-child(1) {
    width: 80px;
}

.transaction-table-wrap th:nth-child(2),
.transaction-table-wrap td:nth-child(2) {
    width: 300px;
}

.transaction-table-wrap th:nth-child(3),
.transaction-table-wrap td:nth-child(3) {
    width: 210px;
}

.transaction-table-wrap th:nth-child(4),
.transaction-table-wrap td:nth-child(4) {
    width: 150px;
}

.transaction-table-wrap th:nth-child(5),
.transaction-table-wrap td:nth-child(5) {
    width: 95px;
}

.transaction-table-wrap th:nth-child(6),
.transaction-table-wrap td:nth-child(6) {
    width: 110px;
}

.transaction-table-wrap th:nth-child(7),
.transaction-table-wrap td:nth-child(7) {
    width: 375px;
}

.transaction-edit-form {
    align-items: stretch;
    border-top: 1px solid var(--line);
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(0, 1fr);
    padding-top: 12px;
}

.transaction-edit-form.compact {
    border-top: 0;
    grid-template-columns: minmax(0, 1fr);
    min-width: 0;
    padding-top: 0;
}

.transaction-edit-form label {
    color: var(--muted);
    display: grid;
    font-size: 12px;
    gap: 5px;
    margin: 0;
}

.transaction-edit-form input:not([type]) {
    min-height: 38px;
}

.transaction-edit-form .check-control {
    align-items: center;
    color: var(--text);
    display: flex;
    gap: 7px;
    min-height: 38px;
    line-height: 1.2;
    min-width: 0;
    white-space: normal;
}

.transaction-edit-form .check-control input {
    width: auto;
}

.transaction-edit-actions {
    align-items: center;
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(78px, auto);
    justify-content: start;
}

.transaction-edit-actions button {
    min-height: 38px;
    padding: 0 12px;
    width: 100%;
}

.transaction-edit-form.compact .check-control {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--line);
    border-radius: 6px;
    justify-content: center;
    min-height: 36px;
    padding: 0 8px;
}

.new-category-fields {
    background: rgba(56, 209, 201, 0.08);
    border: 1px solid rgba(56, 209, 201, 0.28);
    border-radius: 8px;
    display: grid;
    gap: 7px;
    margin-top: 8px;
    padding: 10px;
}

.new-category-fields[hidden] {
    display: none;
}

.planning-choice-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 20px;
}

.planning-choice-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    color: var(--text);
    display: block;
    padding: 18px;
    text-decoration: none;
}

.planning-choice-card.active,
.planning-choice-card:hover {
    border-color: #38d1c9;
    box-shadow: 0 18px 34px rgba(56, 209, 201, 0.16);
}

.planning-choice-card strong {
    color: var(--text);
    display: block;
    font-size: 18px;
    margin-bottom: 8px;
}

.planning-choice-card span {
    color: var(--muted);
    display: block;
    line-height: 1.45;
}

.planning-scenario-panel {
    margin-bottom: 20px;
}

.planning-preview-card {
    align-items: center;
    background: linear-gradient(135deg, rgba(51, 153, 102, 0.18), rgba(56, 209, 201, 0.12));
    border: 1px solid rgba(51, 153, 102, 0.42);
    border-radius: 10px;
    display: grid;
    gap: 14px;
    grid-template-columns: minmax(0, 220px) minmax(0, 1fr);
    margin-bottom: 18px;
    padding: 16px;
}

.planning-preview-card span {
    color: var(--text);
    display: block;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 6px;
}

.planning-preview-card strong {
    color: #339966;
    font-size: 26px;
}

.planning-preview-card p {
    color: var(--text);
    font-weight: 700;
    margin: 0;
}

.scenario-result-card {
    align-items: center;
    background: linear-gradient(135deg, rgba(56, 209, 201, 0.18), rgba(0, 172, 230, 0.14));
    border: 1px solid rgba(56, 209, 201, 0.42);
    border-radius: 10px;
    display: grid;
    gap: 14px;
    grid-template-columns: minmax(0, 220px) minmax(0, 1fr);
    margin-top: 18px;
    padding: 16px;
}

.scenario-result-card span {
    color: var(--text);
    display: block;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 6px;
}

.scenario-result-card strong {
    color: #38d1c9;
    font-size: 30px;
}

.scenario-result-card p {
    color: var(--text);
    font-weight: 700;
    margin: 0;
}

.scenario-snapshot {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 18px;
}

.scenario-snapshot div {
    background: var(--surface-strong);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.scenario-snapshot span {
    color: var(--muted);
    display: block;
    font-size: 13px;
    margin-bottom: 6px;
}

.scenario-snapshot strong {
    color: var(--text);
    font-size: 22px;
}

.scenario-table-wrap {
    margin-top: 18px;
}

.priority-stat-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    margin-bottom: 14px;
}

.priority-stat-grid .stat {
    min-height: 116px;
}

.priority-stat-grid .stat strong {
    font-size: 34px;
}

.dashboard-section-separator {
    align-items: center;
    display: grid;
    gap: 14px;
    grid-template-columns: minmax(18px, 1fr) auto minmax(18px, 1fr);
    margin: 6px 0 14px;
}

.dashboard-section-separator span {
    background: linear-gradient(90deg, transparent, var(--danger));
    border-radius: 999px;
    height: 2px;
}

.dashboard-section-separator span:last-child {
    background: linear-gradient(90deg, var(--danger), transparent);
}

.dashboard-section-separator strong {
    color: var(--danger);
    font-size: 13px;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
}

.dashboard-section-separator.separator-good span {
    background: linear-gradient(90deg, transparent, var(--good));
}

.dashboard-section-separator.separator-good span:last-child {
    background: linear-gradient(90deg, var(--good), transparent);
}

.dashboard-section-separator.separator-good strong {
    color: var(--good);
}

.dashboard-section-separator.separator-bank span {
    background: linear-gradient(90deg, transparent, #38d1c9);
}

.dashboard-section-separator.separator-bank span:last-child {
    background: linear-gradient(90deg, #38d1c9, transparent);
}

.dashboard-section-separator.separator-bank strong {
    color: #38d1c9;
}

.dashboard-section-separator.separator-investments {
    gap: 8px;
    grid-template-columns: minmax(8px, 1fr) auto minmax(8px, 1fr);
}

.dashboard-section-separator.separator-investments strong {
    font-size: clamp(10px, 3vw, 13px);
    white-space: nowrap;
}

.wide-stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 14px;
    padding: 20px;
}

.wide-stat span {
    color: var(--muted);
    display: block;
    font-size: 14px;
    font-weight: 700;
}

.wide-stat strong {
    color: var(--good);
    display: block;
    font-size: 34px;
    margin-top: 4px;
}

.wide-stat em {
    color: var(--danger);
    display: block;
    font-size: 14px;
    font-style: normal;
    font-weight: 700;
    margin-top: 8px;
}

.bank-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stat {
    overflow: hidden;
    padding: 18px;
    position: relative;
}

.card-link {
    color: inherit;
    cursor: pointer;
    display: block;
    text-decoration: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.card-link *,
.card-link:hover *,
.card-link:focus-visible *,
.card-link:active * {
    text-decoration: none;
}

.card-link:hover,
.card-link:focus-visible {
    border-color: rgba(0, 172, 230, 0.58);
    box-shadow: 0 18px 36px rgba(0, 172, 230, 0.14);
    transform: translateY(-2px);
}

.card-link:focus-visible {
    outline: 2px solid rgba(0, 172, 230, 0.75);
    outline-offset: 3px;
}

.stat::before {
    background: var(--primary);
    border-radius: 0 0 6px 0;
    content: "";
    height: 5px;
    left: 0;
    position: absolute;
    top: 0;
    width: 48px;
}

.stat-bills::before,
.stat-cards::before,
.stat-debt::before,
.stat-balances::before,
.stat-mortgage::before {
    background: var(--danger);
}

.stat-credit::before,
.stat-income::before {
    background: var(--good);
}

.stat-usable::before {
    background: var(--good);
}

.stat-bank::before,
.stat-investment::before {
    background: var(--bank-teal);
}

.stat span {
    color: #ffffff;
    display: block;
    font-size: 13px;
    text-transform: capitalize;
}

.stat strong {
    display: block;
    font-size: 26px;
    margin-top: 4px;
}

.stat-subline {
    display: block;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.25;
    margin-top: 5px;
}

.stat-subline-warning {
    color: #f4c542;
}

.stat-bills strong,
.stat-cards strong {
    color: var(--danger);
}

.stat-balances strong {
    color: var(--danger);
}

.stat-mortgage strong {
    color: var(--danger);
}

.stat-bank strong,
.stat-investment strong {
    color: var(--bank-teal);
}

.stat-bank span,
.stat-investment span {
    color: #ffffff;
}

.positive {
    color: var(--good);
}

.negative {
    color: var(--danger);
}

.income-value {
    color: #0f5132;
}

.theme-dark .income-value {
    color: #f4c542;
}

.debt-value {
    color: var(--danger);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.section-head h2 {
    margin: 0 0 4px;
    font-size: 20px;
}

.section-head p {
    margin: 0;
}

.list-stack {
    display: grid;
    gap: 10px;
}

.quick-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.quick-link {
    background: var(--surface-muted);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    display: block;
    padding: 14px;
    text-decoration: none;
}

.quick-link:hover {
    border-color: var(--primary);
}

.quick-link strong,
.quick-link span {
    display: block;
}

.quick-link span {
    color: var(--muted);
    font-size: 14px;
    margin-top: 2px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    border-top: 1px solid var(--line);
    padding-top: 10px;
}

.summary-row:first-child {
    border-top: 0;
    padding-top: 0;
}

.summary-row div span {
    color: var(--muted);
    display: block;
    font-size: 14px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field.full {
    grid-column: 1 / -1;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

label {
    font-weight: 700;
    font-size: 14px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 11px;
    font: inherit;
    background: var(--surface);
    color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(2, 125, 127, 0.16);
    outline: 0;
}

textarea {
    min-height: 96px;
    resize: vertical;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 26px;
}

.check-row input {
    width: auto;
}

.segmented {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.segmented label {
    cursor: pointer;
}

.segmented input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.segmented span {
    background: var(--surface-muted);
    border: 1px solid var(--line);
    border-radius: 6px;
    display: flex;
    justify-content: center;
    min-height: 42px;
    padding: 9px 10px;
}

.segmented input:checked + span {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.theme-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.theme-choice {
    background: var(--surface-muted);
    border: 1px solid var(--line);
    color: var(--text);
    min-height: 42px;
}

.theme-choice.active,
.theme-choice:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

.actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 18px;
}

.compact-actions {
    margin-top: 0;
}

.button,
button {
    border: 0;
    border-radius: 6px;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 14px;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    transition: background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.button.small,
button.small {
    min-height: 34px;
    padding: 0 10px;
    font-size: 14px;
}

.button:hover,
button:hover {
    background: var(--primary-dark);
    box-shadow: 0 10px 22px rgba(2, 125, 127, 0.22);
    transform: translateY(-1px);
}

.button.secondary,
button.secondary {
    background: var(--surface-muted);
    color: var(--text);
}

.topbar .button.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.topbar .button.secondary:hover {
    background: rgba(255, 255, 255, 0.18);
}

.button.secondary:hover,
button.secondary:hover {
    background: #dde5ee;
}

.button.danger,
button.danger {
    background: var(--danger);
}

.sync-overlay {
    align-items: center;
    background: rgba(9, 17, 24, 0.62);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: 24px;
    position: fixed;
    z-index: 1000;
}

.sync-overlay[hidden] {
    display: none;
}

.sync-dialog {
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(9, 17, 24, 0.28);
    color: var(--text);
    display: grid;
    gap: 10px;
    justify-items: center;
    max-width: 380px;
    padding: 24px;
    text-align: center;
    width: min(100%, 380px);
}

.sync-minimize {
    justify-self: end;
    min-height: 32px;
    padding: 0 10px;
}

.sync-dialog strong {
    font-size: 20px;
}

.sync-dialog p {
    color: var(--muted);
    margin: 0;
}

.sync-spinner {
    animation: sync-spin 0.8s linear infinite;
    border: 4px solid var(--surface-muted);
    border-radius: 50%;
    border-top-color: var(--primary);
    height: 44px;
    width: 44px;
}

.sync-minimized-status {
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    bottom: 18px;
    box-shadow: 0 16px 44px rgba(9, 17, 24, 0.22);
    color: var(--text);
    display: flex;
    gap: 12px;
    left: 18px;
    max-width: calc(100vw - 36px);
    padding: 12px;
    position: fixed;
    z-index: 1001;
}

.sync-minimized-status[hidden] {
    display: none;
}

.sync-minimized-status span {
    font-weight: 700;
}

.sync-minimized-status button {
    min-height: 34px;
    padding: 0 12px;
}

@media (max-width: 820px) {
    .sync-minimized-status {
        bottom: calc(96px + env(safe-area-inset-bottom));
        left: 12px;
        right: 12px;
        max-width: none;
    }
}

@keyframes sync-spin {
    to {
        transform: rotate(360deg);
    }
}

.notice,
.error {
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 16px;
}

.notice {
    background: #eaf7f1;
    color: var(--good);
    border: 1px solid #c9ecd9;
}

.error {
    background: #fff1f0;
    color: var(--danger);
    border: 1px solid #f4c7c3;
}

.table-wrap {
    overflow-x: auto;
}

.history-panel {
    margin-bottom: 20px;
}

.dashboard-table {
    margin-bottom: 20px;
}

.light-table {
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 860px;
}

.credit-card-table-wrap {
    overflow-x: auto;
    max-width: 100%;
}

.credit-card-table {
    font-size: 14px;
}

.manual-credit-card-table {
    min-width: 980px;
}

.synced-credit-card-table {
    min-width: 1120px;
}

.credit-card-table th,
.credit-card-table td {
    padding-left: 10px;
    padding-right: 10px;
}

.credit-card-table .pill {
    white-space: normal;
}

.credit-card-table tbody tr {
    border-bottom: 5px solid var(--bank-teal);
}

.credit-card-table tbody tr:last-child {
    border-bottom: 0;
}

.manual-credit-card-table tbody tr:not(:last-child) td {
    border-bottom: 5px solid var(--bank-teal);
}

.manual-credit-card-table tbody tr:not(:last-child) td {
    padding-bottom: 18px;
}

.manual-credit-card-table tbody tr + tr td {
    padding-top: 18px;
}

.synced-card-actions-row {
    display: none;
}

@media (min-width: 1024px) and (hover: hover) and (pointer: fine) {
    .synced-credit-card-table-wrap {
        overflow: visible;
    }

    .synced-credit-card-table {
        border-collapse: separate;
        border-spacing: 0;
        min-width: 0;
        table-layout: fixed;
        width: 100%;
    }

    .synced-credit-card-table thead {
        position: sticky;
        top: 0;
        z-index: 5;
    }

    .synced-credit-card-table thead th {
        background: var(--surface-muted);
        position: relative;
        z-index: 6;
    }

    .synced-credit-card-table th,
    .synced-credit-card-table td {
        font-size: 14px;
        overflow-wrap: anywhere;
        padding-left: 6px;
        padding-right: 6px;
    }

    .synced-credit-card-table thead th {
        font-size: 13px;
    }

    .synced-credit-card-table .pill {
        font-size: 13px;
        padding-left: 7px;
        padding-right: 7px;
    }

    .synced-card-actions-mobile {
        color: var(--muted);
        font-size: 12px;
    }

    .synced-card-actions-mobile .row-actions {
        display: none;
    }

    .synced-card-actions-mobile::after {
        content: "Below";
    }

    .synced-card-actions-row {
        display: table-row;
    }

    .synced-credit-card-table tbody tr:not(.synced-card-actions-row) {
        border-bottom: 0;
    }

    .synced-credit-card-table .synced-card-actions-row td {
        border-bottom: 6px solid var(--bank-teal);
    }

    .synced-card-actions-row td {
        background: var(--surface-muted);
        font-size: 12px;
        padding: 12px 10px 18px;
    }

    .synced-card-actions-row + tr td {
        padding-top: 18px;
    }

    .synced-card-mobile-pills {
        display: none;
    }

    .synced-card-detail-row {
        align-items: start;
        display: grid;
        gap: 14px;
        grid-template-columns: 170px minmax(0, 1fr);
    }

    .synced-card-pills-column {
        align-items: flex-start;
        display: grid;
        gap: 6px;
        justify-items: start;
    }

    .synced-card-actions-panel {
        align-items: end;
        display: grid;
        gap: 8px;
        grid-template-columns: minmax(250px, 1fr) minmax(170px, 0.7fr) repeat(3, max-content);
        justify-content: start;
    }

    .synced-card-actions-panel .plaid-credit-payment-form {
        align-items: end;
        display: grid;
        gap: 8px;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        width: 100%;
    }

    .synced-card-actions-panel .plaid-credit-payment-form:nth-of-type(2) {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .synced-card-actions-panel .inline-form,
    .synced-card-actions-panel button {
        width: auto;
    }

    .synced-card-actions-panel .inline-form button {
        min-width: 0;
        white-space: nowrap;
    }
}

th,
td {
    padding: 13px 14px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

th {
    background: var(--surface-muted);
    font-size: 13px;
    color: var(--muted);
}

tbody tr {
    transition: background 140ms ease;
}

.anchor-target {
    scroll-margin-top: 96px;
}

tbody tr:hover {
    background: rgba(31, 167, 255, 0.05);
}

tr:last-child td {
    border-bottom: 0;
}

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border-radius: 999px;
    padding: 0 9px;
    background: var(--surface-muted);
    color: var(--text);
    font-size: 13px;
    white-space: nowrap;
}

.pill.soon {
    background: #fff4d6;
    color: var(--warning);
}

.pill.overdue {
    background: #fff1f0;
    color: var(--danger);
}

.pill.needs-paid {
    background: #fff4d6;
    color: var(--warning);
    font-weight: 700;
}

.bill-last-paid-line {
    color: #f4c542;
    display: inline-block;
    font-size: 12px;
    font-weight: 800;
    margin-top: 3px;
}

.bill-payment-progress {
    color: #f4c542;
    display: inline-block;
    font-size: 12px;
    font-weight: 800;
    margin-top: 5px;
}

.muted {
    color: var(--muted);
}

.row-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.inline-form {
    display: inline;
}

.balance-form {
    align-items: center;
    display: flex;
    gap: 8px;
    min-width: 220px;
}

.balance-form input {
    min-width: 110px;
}

.income-wire-form {
    display: grid;
    gap: 1rem;
    margin-bottom: 1rem;
}

.nested-table-wrap {
    margin-top: 1rem;
}

.bill-payment-form {
    align-items: center;
    display: flex;
    gap: 8px;
}

.bill-payment-form input {
    max-width: 125px;
    min-width: 0;
}

.plaid-credit-payment-form {
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(0, 1fr);
    max-width: 100%;
    width: 100%;
}

.plaid-credit-payment-form label {
    display: grid;
    gap: 4px;
}

.plaid-credit-payment-form span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.plaid-credit-payment-form input {
    max-width: 100%;
    min-width: 0;
    width: 100%;
}

.plaid-credit-payment-form button {
    min-width: 0;
    width: 100%;
}

.empty {
    background: var(--surface);
    border: 1px dashed var(--line);
    border-radius: 8px;
    padding: 28px;
    text-align: center;
}

.mobile-tabbar {
    display: none;
}

.theme-dark .notice {
    background: rgba(99, 230, 174, 0.12);
    border-color: rgba(99, 230, 174, 0.30);
}

.theme-dark .error {
    background: rgba(255, 102, 125, 0.13);
    border-color: rgba(255, 102, 125, 0.34);
}

@media (max-width: 820px) {
    html,
    body {
        max-width: 100%;
        overflow-x: hidden;
    }

    body {
        padding-bottom: calc(94px + env(safe-area-inset-bottom));
    }

    .page {
        padding-top: 18px;
    }

    .topbar-inner,
    .page-title {
        flex-direction: column;
        align-items: stretch;
    }

    .topbar {
        box-shadow: 0 8px 22px rgba(7, 20, 33, 0.16);
    }

    .topbar-inner {
        align-items: center;
        justify-content: center;
        min-height: 68px;
    }

    .topbar .nav,
    .topbar .account-menu,
    .topbar .auth-nav {
        display: none;
    }

    .brand {
        justify-content: center;
        min-width: 0;
    }

    .brand-logo {
        height: 42px;
        width: 42px;
    }

    .brand strong {
        font-size: 20px;
    }

    .dashboard-title {
        background: var(--surface);
        border: 1px solid var(--line);
        border-radius: 8px;
        box-shadow: var(--shadow);
        padding: 16px;
    }

    .dashboard-title h1 {
        font-size: 28px;
    }

    .dashboard-title p {
        margin-bottom: 0;
    }

    .dashboard-hero {
        grid-template-columns: 1fr;
    }

    .hero-balance-card,
    .hero-insight-card {
        padding: 18px;
    }

    .hero-balance-card strong {
        font-size: 38px;
    }

    .nav {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .brand,
    .account-menu {
        min-width: 0;
    }

    .account-menu {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .stats-grid,
    .estimated-stats-grid,
    .bank-stats-grid,
    .scenario-snapshot {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .transaction-insight-grid {
        grid-template-columns: 1fr;
    }

    .transaction-edit-form .check-control {
        justify-content: flex-start;
        width: 100%;
    }

    .transaction-edit-actions {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(68px, auto);
        width: 100%;
    }

    .transaction-edit-actions button {
        grid-column: auto;
        width: 100%;
    }

    .planning-choice-grid {
        grid-template-columns: 1fr;
    }

    .planning-preview-card,
    .scenario-result-card {
        grid-template-columns: 1fr;
    }

    .stat {
        min-height: 116px;
        padding: 15px;
    }

    .stat span {
        font-size: 12px;
        font-weight: 800;
    }

    .stat strong {
        font-size: 22px;
        overflow-wrap: anywhere;
    }

    .stat-bills::before,
    .stat-cards::before,
    .stat-debt::before,
    .stat-balances::before,
    .stat-mortgage::before {
        background: var(--danger);
    }

    .stat-bills span,
    .stat-cards span,
    .stat-debt span,
    .stat-mortgage span,
    .stat-balances span,
    .debt-value {
        color: var(--danger);
    }

    .stat-bills span,
    .stat-cards span,
    .stat-debt span,
    .stat-mortgage span,
    .stat-balances span {
        color: #ffffff;
    }

    .stat-income::before {
        background: var(--good);
    }

    .income-value {
        color: #0f5132;
    }

    .stat-income span {
        color: #ffffff;
    }

    .theme-dark .income-value {
        color: #f4c542;
    }

    .theme-dark .stat-income span {
        color: #ffffff;
    }

    .stat-credit::before {
        background: var(--good);
    }

    .positive {
        color: var(--good);
    }

    .stat-credit span {
        color: #ffffff;
    }

    .stat-usable::before {
        background: var(--good);
    }

    .stat-balances span,
    .stat-usable span {
        color: #ffffff;
    }

    .stat-bank strong,
    .stat-investment strong {
        color: var(--bank-teal);
    }

    .stat-bank span,
    .stat-investment span {
        color: #ffffff;
    }

    .stat-bank::before,
    .stat-investment::before {
        background: var(--bank-teal);
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .manage-details-panel {
        display: none;
    }

    .quick-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .check-row {
        padding-top: 0;
    }

    .compact-actions {
        display: none;
    }

    .mobile-page-actions {
        display: grid;
        gap: 10px;
        margin-top: 0;
    }

    .mobile-page-actions .button,
    .mobile-page-actions button,
    .mobile-page-actions form {
        width: 100%;
    }

    .table-wrap {
        background: transparent;
        border: 0;
        box-shadow: none;
        overflow: visible;
        padding: 0;
    }

    .credit-card-table-wrap {
        overflow: visible;
    }

    .credit-card-table,
    .manual-credit-card-table,
    .synced-credit-card-table {
        min-width: 0;
        max-width: 100%;
        width: 100%;
    }

    .synced-credit-card-table th {
        position: static;
        top: auto;
        z-index: auto;
    }

    .table-wrap .section-head {
        background: var(--surface);
        border: 1px solid var(--line);
        border-radius: 8px;
        box-shadow: var(--shadow);
        margin-bottom: 12px;
        padding: 16px;
    }

    table,
    thead,
    tbody,
    tr,
    th,
    td {
        display: block;
        min-width: 0;
        max-width: 100%;
        width: 100%;
    }

    thead {
        height: 1px;
        overflow: hidden;
        position: absolute;
        width: 1px;
    }

    tbody {
        display: grid;
        gap: 12px;
    }

    tr {
        background: var(--surface);
        border: 1px solid var(--line);
        border-radius: 8px;
        box-shadow: var(--shadow);
        min-width: 0;
        max-width: 100%;
        padding: 14px;
    }

    tr:hover {
        transform: none;
    }

    td {
        border-bottom: 1px solid var(--line);
        display: grid;
        gap: 6px;
        grid-template-columns: minmax(82px, 0.36fr) minmax(0, 1fr);
        min-width: 0;
        max-width: 100%;
        padding: 10px 0;
        text-align: right;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    td:first-child {
        border-top: 0;
        display: block;
        padding-top: 0;
        text-align: left;
    }

    td:last-child {
        border-bottom: 0;
        padding-bottom: 0;
    }

    td::before {
        color: var(--muted);
        content: attr(data-label);
        font-size: 12px;
        font-weight: 800;
        text-align: left;
        text-transform: uppercase;
    }

    td:first-child::before {
        content: none;
    }

    .row-actions,
    .balance-form,
    .bill-payment-form,
    .plaid-credit-payment-form {
        align-items: stretch;
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
        width: 100%;
    }

    td input,
    td select {
        min-width: 0;
        max-width: 100%;
    }

    .row-actions .button,
    .row-actions button,
    .balance-form .button,
    .balance-form button,
    .bill-payment-form .button,
    .bill-payment-form button,
    .plaid-credit-payment-form .button,
    .plaid-credit-payment-form button {
        min-width: 0;
        width: 100%;
    }

    .bill-payment-form input {
        max-width: 100%;
        width: 100%;
    }

    td .inline-form {
        min-width: 0;
        max-width: 100%;
        width: 100%;
    }

    .pill {
        max-width: 100%;
        overflow-wrap: anywhere;
        white-space: normal;
    }

    .summary-row {
        align-items: stretch;
        flex-direction: column;
    }

    .summary-row .row-actions {
        margin-top: 4px;
    }

    .mobile-tabbar {
        align-items: center;
        background: #00ace6;
        border: 1px solid rgba(255, 255, 255, 0.10);
        border-bottom: 0;
        border-radius: 24px 24px 0 0;
        bottom: 0;
        backdrop-filter: blur(14px);
        box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.22);
        display: grid;
        grid-template-columns: 1fr 86px 1fr;
        gap: 2px;
        left: 0;
        min-height: 76px;
        padding: 9px 28px calc(9px + env(safe-area-inset-bottom));
        position: fixed;
        right: 0;
        z-index: 20;
    }

    .mobile-tab-item,
    .mobile-more-menu summary {
        align-items: center;
        color: #f7fbf9;
        display: flex;
        flex-direction: column;
        font-size: 11px;
        font-weight: 800;
        gap: 4px;
        justify-content: center;
        min-height: 58px;
        text-decoration: none;
    }

    .mobile-tab-item svg,
    .mobile-more-menu svg {
        fill: currentColor;
        height: 24px;
        width: 24px;
    }

    .mobile-tab-item:hover {
        background: #339966;
        border-radius: 12px;
        color: #ffffff;
    }

    .mobile-more-menu summary:hover,
    .mobile-more-menu summary:focus,
    .mobile-more-menu summary:active,
    .mobile-more-menu[open] summary {
        background: transparent;
        color: #f7fbf9;
        outline: 0;
    }

    .mobile-add-menu,
    .mobile-more-menu {
        position: relative;
    }

    .mobile-add-menu summary,
    .mobile-more-menu summary {
        cursor: pointer;
        list-style: none;
    }

    .mobile-add-menu summary::-webkit-details-marker,
    .mobile-more-menu summary::-webkit-details-marker {
        display: none;
    }

    .mobile-add-menu summary {
        align-items: center;
        background: #339966;
        border: 6px solid #f7f8fa;
        border-radius: 999px;
        box-shadow: 0 8px 22px rgba(0, 0, 0, 0.24);
        color: #ffffff;
        display: flex;
        height: 74px;
        justify-content: center;
        margin: -34px auto 0;
        width: 74px;
    }

    .theme-dark .mobile-add-menu summary {
        border-color: #15181b;
    }

    .mobile-add-menu summary span {
        display: block;
        font-size: 48px;
        font-weight: 900;
        line-height: 0.85;
        margin-top: -3px;
    }

    .mobile-popover {
        background: var(--surface);
        border: 1px solid var(--line);
        border-radius: 8px;
        box-shadow: 0 18px 40px rgba(0, 0, 0, 0.26);
        display: grid;
        gap: 4px;
        min-width: 190px;
        padding: 8px;
        position: absolute;
        z-index: 30;
    }

    .mobile-popover a {
        border-radius: 6px;
        color: var(--text);
        font-weight: 800;
        padding: 11px 12px;
        text-decoration: none;
    }

    .mobile-menu-form {
        margin: 0;
    }

    .mobile-menu-button {
        background: transparent;
        border: 0;
        border-radius: 6px;
        box-shadow: none;
        color: var(--text);
        font-weight: 800;
        justify-content: flex-start;
        min-height: auto;
        padding: 11px 12px;
        text-align: left;
        transform: none;
        width: 100%;
    }

    .mobile-popover a:hover,
    .mobile-menu-button:hover {
        background: #339966;
        color: #ffffff;
    }

    .mobile-popover .pwa-install-button,
    .mobile-popover .pwa-install-button:hover,
    .mobile-popover .pwa-install-button:focus,
    .mobile-popover .pwa-install-button:active {
        background: transparent;
        box-shadow: none;
        color: #f4c542;
        transform: none;
    }

    .mobile-add-popover {
        bottom: 88px;
        left: 50%;
        transform: translateX(-50%);
    }

    .mobile-more-popover {
        bottom: 76px;
        right: 0;
    }
}

@media (max-width: 520px) {
    .stats-grid,
    .estimated-stats-grid,
    .bank-stats-grid,
    .scenario-snapshot {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .transaction-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .transaction-filter-panel {
        padding: 13px;
    }

    .transaction-main,
    .transaction-meta {
        align-items: flex-start;
    }

    .transaction-edit-form,
    .transaction-edit-form.compact {
        grid-template-columns: 1fr;
        min-width: 0;
    }

    .transaction-edit-form .check-control {
        justify-content: flex-start;
    }

    .transaction-edit-actions {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(68px, auto);
    }

    .stat {
        min-height: 104px;
        padding: 13px 11px;
    }

    .stat::before {
        width: 38px;
    }

    .stat span {
        font-size: 11px;
        line-height: 1.25;
    }

    .stat strong {
        font-size: clamp(17px, 5.4vw, 21px);
        line-height: 1.12;
    }

    .topbar-inner,
    .page {
        max-width: calc(100vw - 20px);
        width: calc(100% - 20px);
    }

    .quick-grid,
    .balance-form {
        grid-template-columns: 1fr;
        flex-direction: column;
        align-items: stretch;
    }
}
