* {
    box-sizing: border-box;
}

:root {
    color-scheme: light;
}

body {
    margin: 0;
    background: #f4f4f2;
    color: #111;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

main {
    max-width: 620px;
    min-height: 100vh;
    margin: 0 auto;
    padding: 12px 12px 116px;
}

h2 {
    font-size: 18px;
    margin: 22px 0 10px;
}

p {
    margin: 4px 0 0;
    color: #666;
}

.app-view {
    display: none;
}

.app-view.active {
    display: block;
}

.card,
.transaction,
.balance-card,
.error {
    background: #fff;
    border: 1px solid #deded9;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .035);
}

.error {
    color: #8a1f11;
    background: #fff2ef;
    padding: 12px;
    margin-bottom: 12px;
}

.dashboard {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, .82fr);
    gap: 10px;
    margin-bottom: 12px;
}

.dashboard-card {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.balance-card {
    padding: 12px;
}

.balance-card span {
    display: block;
    color: #666;
    font-size: 12px;
    margin-bottom: 4px;
}

.balance-card strong {
    font-size: 17px;
}

.dashboard-lines {
    display: grid;
    gap: 8px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #ededeb;
}

.dashboard-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: baseline;
    gap: 8px;
}

.dashboard-line span {
    min-width: 0;
    margin: 0;
    line-height: 1.25;
}

.dashboard-line strong {
    white-space: nowrap;
    font-size: 13px;
}

.dashboard-line-muted {
    display: block;
}

.dashboard-stack {
    display: grid;
    gap: 10px;
}

.private-card {
    min-height: calc(50% - 5px);
}

.tax-estimate {
    margin-bottom: 12px;
}

.project-dashboard-card {
    margin-bottom: 12px;
}

.project-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.project-card-header span {
    margin: 0 0 2px;
}

.dashboard-project-list {
    margin-top: 12px;
}

.tax-estimate-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.tax-estimate-header span {
    margin: 0;
}

.tax-estimate-header p {
    max-width: 360px;
    font-size: 12px;
    line-height: 1.35;
}

.tax-year-form {
    flex: 0 0 120px;
}

.tax-year-form label {
    margin: 0;
}

.tax-year-form select {
    padding: 9px 10px;
    border-radius: 12px;
}

.form {
    padding: 16px;
}

.amount-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #eee;
    padding-bottom: 14px;
    margin-bottom: 14px;
}

.amount-wrap span {
    font-size: 34px;
    font-weight: 650;
    color: #555;
}

.amount {
    border: 0;
    outline: 0;
    width: 100%;
    font-size: 48px;
    line-height: 1;
    font-weight: 750;
    padding: 6px 0;
}

.amount::placeholder {
    color: #c8c8c8;
}

label {
    display: block;
    color: #666;
    font-size: 12px;
    margin: 14px 0 6px;
}

input,
select,
button {
    width: 100%;
    font: inherit;
}

input,
select {
    border: 1px solid #d7d7d3;
    background: #fff;
    border-radius: 13px;
    padding: 13px;
    margin-top: 6px;
}

.chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 2px 0;
    scrollbar-width: none;
}

.chips::-webkit-scrollbar {
    display: none;
}

.chip {
    width: auto;
    white-space: nowrap;
    border: 1px solid #d7d7d3;
    background: #f9f9f7;
    border-radius: 999px;
    padding: 10px 13px;
    font-size: 14px;
}

.chip.active {
    background: #111;
    color: #fff;
    border-color: #111;
}

.hidden-select {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
}

.account-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: end;
    gap: 8px;
}

.transaction-mode-grid,
.transfer-account-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.transfer-account-grid {
    grid-template-columns: 1fr 1fr;
}

[data-mode-panel][hidden] {
    display: none;
}

.mode-option {
    margin: 0;
}

.mode-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.mode-option span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border: 1px solid #d7d7d3;
    border-radius: 13px;
    background: #f9f9f7;
    color: #111;
    font-size: 14px;
    font-weight: 650;
}

.mode-option input:checked + span {
    background: #111;
    border-color: #111;
    color: #fff;
}

.arrow {
    padding-bottom: 13px;
    color: #777;
}

.two-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.submit,
.secondary-button,
.danger-button {
    border: 0;
    border-radius: 16px;
    background: #111;
    color: #fff;
    padding: 16px;
    font-weight: 650;
}

.submit {
    position: sticky;
    bottom: 12px;
    margin-top: 16px;
}

.secondary-button {
    background: #eee;
    color: #111;
}

.danger-button {
    background: #fff2ef;
    color: #8a1f11;
    border: 1px solid #ffd4cb;
}

.danger-button:disabled {
    color: #aaa;
    background: #f3f3f1;
    border-color: #deded9;
    cursor: not-allowed;
}

.transaction {
    padding: 14px;
    margin-bottom: 10px;
}

.transaction-top {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 5px;
}

.meta {
    color: #666;
    font-size: 14px;
    line-height: 1.35;
}

.actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
}

.actions a,
.actions button {
    display: block;
    width: 100%;
    border: 0;
    border-radius: 12px;
    background: #eee;
    color: #111;
    text-align: center;
    text-decoration: none;
    padding: 10px;
    font-size: 14px;
}

.actions form {
    margin: 0;
}

.empty {
    color: #666;
    background: #fff;
    border: 1px dashed #d7d7d3;
    border-radius: 16px;
    padding: 16px;
}

.list-view,
.projects {
    padding: 0 2px;
}

.view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.view-header h2 {
    margin: 0;
}

.item-list,
.project-list,
.account-list,
.category-list {
    display: block;
}

.project-list,
.account-list,
.category-list {
    border-top: 1px solid #deded9;
}

.project-row,
.account-row,
.category-row {
    padding: 12px 0;
    border-bottom: 1px solid #deded9;
}

.project-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
}

.project-summary-main {
    min-width: 0;
}

.project-summary-main strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 15px;
}

.project-summary-main span {
    display: block;
    color: #666;
    font-size: 12px;
    line-height: 1.35;
}

.project-summary .secondary-button {
    width: auto;
    padding: 9px 11px;
    border-radius: 10px;
    font-size: 13px;
}

.project-form label,
.account-form label,
.category-form label {
    margin-top: 10px;
}

.account-group {
    margin-bottom: 18px;
}

.account-group-title {
    display: flex;
    justify-content: space-between;
    color: #666;
    font-size: 12px;
    font-weight: 650;
    padding: 10px 0 8px;
    text-transform: uppercase;
}

.dialog-danger-form {
    padding: 0 16px 16px;
}

.dialog-danger-form .danger-button {
    padding: 12px;
    border-radius: 12px;
}

.settings {
    padding: 0 2px;
}

.settings-section {
    padding: 0;
}

.settings-section h2 {
    margin: 0 0 10px;
}

.app-dialog {
    width: min(620px, calc(100% - 24px));
    max-height: calc(100vh - 32px);
    padding: 0;
    border: 1px solid #deded9;
    border-radius: 24px;
    background: #fff;
    color: #111;
    box-shadow: 0 26px 80px rgba(0, 0, 0, .22);
}

.app-dialog::backdrop {
    background: rgba(17, 17, 17, .38);
    backdrop-filter: blur(3px);
}

.app-dialog .submit {
    position: static;
}

.dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.dialog-header h2 {
    margin: 0;
}

.icon-button {
    width: 40px;
    height: 40px;
    border: 1px solid #deded9;
    border-radius: 50%;
    background: #f4f4f2;
    color: #111;
    font-size: 24px;
    line-height: 1;
}

.bottom-tabs {
    position: fixed;
    left: 50%;
    bottom: 16px;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    width: min(460px, calc(100% - 28px));
    padding: 5px;
    border: 1px solid #deded9;
    border-radius: 999px;
    background: rgba(255, 255, 255, .92);
    box-shadow: 0 18px 44px rgba(0, 0, 0, .16);
    backdrop-filter: blur(14px);
    transform: translateX(-50%);
}

.bottom-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 999px;
    color: #555;
    text-decoration: none;
    font-size: 14px;
    font-weight: 650;
    white-space: nowrap;
}

.bottom-tab.active {
    background: #111;
    color: #fff;
}

@media (max-width: 560px) {
    main {
        padding: 10px 10px 116px;
    }

    .dashboard,
    .two-cols,
    .account-grid,
    .transfer-account-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-stack {
        grid-template-columns: 1fr 1fr;
    }

    .arrow {
        display: none;
    }

    .amount {
        font-size: 44px;
    }

    .project-summary {
        grid-template-columns: 1fr;
    }

    .project-summary .secondary-button {
        width: 100%;
    }

    .app-dialog {
        width: calc(100% - 20px);
        max-height: calc(100vh - 20px);
    }

    .tax-estimate-header {
        display: grid;
    }

    .tax-year-form {
        width: 100%;
        flex: auto;
    }

    .bottom-tabs {
        bottom: 10px;
        width: calc(100% - 20px);
    }

    .bottom-tab {
        padding: 0 5px;
        font-size: 12px;
    }

}

@media (max-width: 380px) {
    .dashboard-stack {
        grid-template-columns: 1fr;
    }

    .bottom-tab {
        padding: 0 2px;
        font-size: 10px;
    }
}

.settings-link-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 14px;
    margin-bottom: 10px;
    color: inherit;
    text-decoration: none;
    background: #fff;
    border: 1px solid #deded9;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .035);
}

.settings-link-row strong,
.settings-link-row small {
    display: block;
}

.settings-link-row small {
    margin-top: 4px;
    color: #666;
    font-size: 13px;
    line-height: 1.35;
}

.settings-link-arrow {
    color: #666;
}

.import-upload-form {
    margin-bottom: 12px;
    background: #fff;
    border: 1px solid #deded9;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .035);
}

.import-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.import-stat {
    padding: 12px;
    background: #fff;
    border: 1px solid #deded9;
    border-radius: 16px;
}

.import-stat span {
    display: block;
    color: #666;
    font-size: 12px;
    margin-bottom: 4px;
}

.import-preview-list {
    margin-bottom: 12px;
}

.import-preview-row {
    padding: 14px;
    margin-bottom: 10px;
    background: #fff;
    border: 1px solid #deded9;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .035);
}

.import-pill {
    display: inline-flex;
    width: auto;
    margin-top: 8px;
    border-radius: 999px;
    padding: 5px 9px;
    font-size: 13px;
}

.import-pill-import {
    background: #edf8ef;
    color: #256335;
}

.import-pill-transfer {
    background: #dceee6;
    color: #165c3f;
}

.import-pill-duplicate {
    background: #f1f1ee;
    color: #555;
}

.import-pill-error {
    background: #fff2ef;
    color: #8a1f11;
}
