@font-face {
    font-style: normal;
    font-display: swap;
    font-family: "Inter";
    src: url(/asset/media/inter.woff2);
}
:root {
    --bg: #f8f6f3;
    --surface: #ffffff;
    --border: #e5ded5;
    --black: #1a1816;
    --gray: #7a7268;
    --gray-light: #ede8e2;
    --brown: #8b5e3c;
    --brown-light: #f5e9de;
    --brown-mid: #b8845c;
    --sage: #4a6650;
    --sage-light: #e4ede6;
    --danger: #8b3a3a;
    --danger-light: #f5e5e5;
}
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body {
    font-family: "Inter", sans-serif;
    background: var(--bg);
    color: var(--black);
    min-height: 100vh;
    padding-bottom: 48px;
}
header {
    background: var(--black);
    color: #fff;
    padding: 18px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.header-left h1 {
    font-size: 1.05rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.header-left span {
    font-size: 0.62rem;
    opacity: 0.4;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}
.header-actions {
    display: flex;
    gap: 7px;
    position: relative;
}
.hdr-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    padding: 6px 11px;
    border-radius: 7px;
    font-size: 0.72rem;
    font-weight: 500;
    cursor: pointer;
    letter-spacing: 0.4px;
    transition: background 0.2s;
    font-family: inherit;
}
.hdr-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}
.hdr-btn.import-btn {
    background: rgba(74, 102, 80, 0.5);
    border-color: rgba(74, 102, 80, 0.8);
}
.hdr-btn.import-btn:hover {
    background: rgba(74, 102, 80, 0.7);
}
.export-wrap {
    position: relative;
}
.export-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--black);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    overflow: hidden;
    min-width: 175px;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-4px);
    transition: all 0.18s;
}
.export-menu.open {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
}
.exp-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 14px;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    transition: background 0.15s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
}
.exp-item:hover {
    background: rgba(255, 255, 255, 0.1);
}
.exp-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
}
.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 16px;
}
.balance-card {
    background: var(--brown);
    color: #fff;
    border-radius: 18px;
    padding: 28px 24px 24px;
    margin: 20px 0 14px;
    position: relative;
    overflow: hidden;
}
.balance-card::before {
    content: "";
    position: absolute;
    top: -40px;
    right: -30px;
    width: 130px;
    height: 130px;
    background: rgba(255, 255, 255, 0.07);
    border-radius: 50%;
}
.balance-card::after {
    content: "";
    position: absolute;
    bottom: -25px;
    right: 50px;
    width: 90px;
    height: 90px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
}
.balance-label {
    font-size: 0.7rem;
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}
.balance-amount {
    font-size: 2.3rem;
    font-weight: 600;
    letter-spacing: -1px;
    position: relative;
}
.balance-amount.negative {
    color: #ffaaaa;
}
.balance-sub {
    font-size: 0.72rem;
    opacity: 0.55;
    margin-top: 5px;
    position: relative;
}
.stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--surface);
    border-radius: 13px;
    padding: 16px;
    border: 1px solid var(--border);
}
.stat-label {
    font-size: 0.68rem;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 7px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.stat-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
}
.income-dot {
    background: var(--sage);
}
.expense-dot {
    background: var(--brown-mid);
}
.stat-amount {
    font-size: 1.1rem;
    font-weight: 600;
}
.income-val {
    color: var(--sage);
}
.expense-val {
    color: var(--brown);
}
.section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--gray);
    margin-bottom: 10px;
}
.add-form {
    background: var(--surface);
    border-radius: 16px;
    padding: 20px;
    border: 1px solid var(--border);
    margin-bottom: 22px;
}
.form-mode {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--brown-light);
    border: 1px solid #e8d5c8;
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 14px;
    font-size: 0.8rem;
    color: var(--brown);
}
.add-form.editing .form-mode {
    display: flex;
}
.form-mode strong {
    font-weight: 600;
}
.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 10px;
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.form-group.full {
    grid-column: 1/-1;
}
.form-group.full input {
    width: 100%;
}
label {
    font-size: 0.68rem;
    color: var(--gray);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
input,
select,
textarea {
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 0.88rem;
    background: var(--bg);
    color: var(--black);
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}
input:focus,
select:focus,
textarea:focus {
    border-color: var(--sage);
}
input::placeholder,
textarea::placeholder {
    color: #b0a898;
}
textarea {
    width: 100%;
    resize: vertical;
    min-height: 90px;
    line-height: 1.5;
}
.type-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.type-btn {
    padding: 9px;
    font-size: 0.85rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    background: transparent;
    color: var(--gray);
    transition: all 0.18s;
    font-family: inherit;
}
.type-btn.active-income {
    background: var(--sage-light);
    color: var(--sage);
}
.type-btn.active-expense {
    background: var(--brown-light);
    color: var(--brown);
}
.btn-add {
    width: 100%;
    padding: 12px;
    background: var(--sage);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 4px;
    font-family: inherit;
    letter-spacing: 0.3px;
    transition: background 0.2s;
}
.btn-add:hover {
    background: #3d5642;
}
.btn-cancel-edit {
    width: 100%;
    padding: 11px;
    background: var(--gray-light);
    color: var(--black);
    border: none;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    font-family: inherit;
    letter-spacing: 0.3px;
    transition: background 0.2s;
    display: none;
}
.btn-cancel-edit:hover {
    background: #ddd8d0;
}
.add-form.editing .btn-cancel-edit {
    display: block;
}
.add-form.editing .btn-add {
    background: var(--brown);
}
.add-form.editing .btn-add:hover {
    background: #6e4a2c;
}
.tx-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.filter-tabs {
    display: flex;
    gap: 5px;
}
.filter-tab {
    font-size: 0.68rem;
    padding: 4px 10px;
    border-radius: 20px;
    border: 1.5px solid var(--border);
    background: transparent;
    color: var(--gray);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
}
.filter-tab.active {
    background: var(--black);
    color: #fff;
    border-color: var(--black);
}
.tx-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 12px;
}
.page-info {
    flex: 1;
    text-align: center;
    font-size: 0.7rem;
    color: var(--gray);
    line-height: 1.4;
}
.page-count {
    font-size: 0.65rem;
    opacity: 0.7;
}
.page-btn {
    padding: 6px 12px;
    border-radius: 18px;
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--black);
    font-size: 0.7rem;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
    min-width: 74px;
}
.page-btn:hover {
    border-color: var(--brown-mid);
    color: var(--brown);
}
.page-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.tx-group {
    margin-top: 10px;
}
.group-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--gray);
    padding: 6px 10px;
    border-radius: 10px;
    background: rgba(26, 24, 22, 0.03);
    margin-bottom: 6px;
    display: inline-block;
    letter-spacing: 0.2px;
}
.tx-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 13px;
    padding: 13px 14px;
    display: flex;
    align-items: center;
    gap: 11px;
    animation: fadeIn 0.2s ease;
    margin-bottom: 6px;
    transition: border-color 0.2s;
}
.tx-item:hover {
    border-color: var(--brown-mid);
    cursor: pointer;
}
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}
.tx-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    flex-shrink: 0;
}
.tx-icon.income {
    background: var(--sage-light);
}
.tx-icon.expense {
    background: var(--brown-light);
}
.tx-info {
    flex: 1;
    min-width: 0;
}
.tx-desc {
    font-size: 0.88rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tx-meta {
    font-size: 0.7rem;
    color: var(--gray);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tx-right {
    text-align: right;
    flex-shrink: 0;
}
.tx-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.tx-edit {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray);
    padding: 4px;
    font-size: 0.92rem;
    line-height: 1;
    transition: color 0.15s;
    flex-shrink: 0;
}
.tx-edit:hover {
    color: var(--sage);
}
.tx-amount {
    font-size: 0.92rem;
    font-weight: 600;
}
.tx-amount.income {
    color: var(--sage);
}
.tx-amount.expense {
    color: var(--brown);
}
.tx-del {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-light);
    padding: 4px 4px 4px 8px;
    font-size: 0.9rem;
    line-height: 1;
    transition: color 0.15s;
    flex-shrink: 0;
}
.tx-del:hover {
    color: var(--danger);
}
.copyright {
    text-align: center;
    font-size: 0.75rem;
    color: var(--gray);
    margin: 30px 0 10px;
}
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray);
    font-size: 0.85rem;
}
.empty-state div {
    font-size: 2rem;
    margin-bottom: 10px;
}
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--black);
    color: #fff;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 0.82rem;
    opacity: 0;
    transition: all 0.3s;
    pointer-events: none;
    white-space: nowrap;
    z-index: 999;
}
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.toast.success {
    background: var(--sage);
}
.toast.error {
    background: var(--danger);
}
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}
.modal-overlay.show {
    opacity: 1;
    pointer-events: all;
}
.modal {
    background: var(--surface);
    border-radius: 18px;
    padding: 24px;
    width: 100%;
    max-width: 380px;
    transform: translateY(12px);
    transition: transform 0.2s;
}
.modal-overlay.show .modal {
    transform: translateY(0);
}
.modal h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 8px;
}
.modal p {
    font-size: 0.83rem;
    color: var(--gray);
    margin-bottom: 18px;
    line-height: 1.55;
}
.modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}
.modal-btn {
    flex: 1;
    padding: 11px;
    border-radius: 9px;
    font-size: 0.83rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    border: none;
    transition: background 0.2s;
}
.modal-btn.cancel {
    background: var(--gray-light);
    color: var(--black);
}
.modal-btn.cancel:hover {
    background: #ddd8d0;
}
.modal-btn.merge {
    background: var(--sage);
    color: #fff;
}
.modal-btn.merge:hover {
    background: #3d5642;
}
.modal-btn.replace {
    background: var(--brown);
    color: #fff;
}
.modal-btn.replace:hover {
    background: #6e4a2c;
}
.modal-btn.danger {
    background: var(--danger);
    color: #fff;
}
.modal-btn.danger:hover {
    background: #6e2e2e;
}
.modal-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.del-item-preview {
    background: var(--danger-light);
    border: 1px solid #e8cccc;
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.del-item-preview .di-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}
.del-item-preview .di-icon.income {
    background: var(--sage-light);
}
.del-item-preview .di-icon.expense {
    background: var(--brown-light);
}
.del-item-preview .di-info {
    flex: 1;
    min-width: 0;
}
.del-item-preview .di-desc {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.del-item-preview .di-meta {
    font-size: 0.7rem;
    color: var(--gray);
    margin-top: 2px;
}
.del-item-preview .di-amount {
    font-size: 0.85rem;
    font-weight: 600;
    flex-shrink: 0;
}
.del-item-preview .di-amount.income {
    color: var(--sage);
}
.del-item-preview .di-amount.expense {
    color: var(--brown);
}
.import-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border: 1.5px solid var(--border);
    border-radius: 9px;
    overflow: hidden;
    margin-bottom: 16px;
}
.import-tab {
    padding: 9px;
    font-size: 0.8rem;
    font-weight: 500;
    border: none;
    background: transparent;
    color: var(--gray);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.18s;
}
.import-tab.active {
    background: var(--black);
    color: #fff;
}
.import-panel {
    display: none;
}
.import-panel.active {
    display: block;
}
.import-drop {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 26px 20px;
    text-align: center;
    color: var(--gray);
    font-size: 0.83rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 14px;
}
.import-drop:hover,
.import-drop.drag {
    border-color: var(--sage);
    background: var(--sage-light);
    color: var(--sage);
}
.import-drop .drop-icon {
    font-size: 1.7rem;
    margin-bottom: 7px;
}
#fileInput {
    display: none;
}
.paste-area-wrap {
    margin-bottom: 10px;
}
.paste-area-wrap label {
    display: block;
    margin-bottom: 6px;
}
.paste-hint {
    font-size: 0.72rem;
    color: var(--gray);
    margin-top: 6px;
    margin-bottom: 12px;
}
.paste-actions {
    display: flex;
    gap: 7px;
    margin-bottom: 14px;
}
.paste-btn {
    flex: 1;
    padding: 9px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    border: 1.5px solid var(--border);
    background: var(--bg);
    color: var(--black);
    transition: all 0.15s;
}
.paste-btn:hover {
    border-color: var(--sage);
    color: var(--sage);
}
.paste-btn.primary {
    background: var(--sage);
    color: #fff;
    border-color: var(--sage);
}
.paste-btn.primary:hover {
    background: #3d5642;
}
@media (max-width: 400px) {
    header {
        padding: 15px 14px;
    }
    .header-left h1 {
        font-size: 0.95rem;
    }
    .hdr-btn {
        padding: 5px 9px;
        font-size: 0.68rem;
    }
    .container {
        padding: 0 12px;
    }
    .balance-amount {
        font-size: 1.9rem;
    }
    .add-form {
        padding: 16px;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .tx-item {
        padding: 11px 12px;
        gap: 9px;
    }
    .tx-icon {
        width: 34px;
        height: 34px;
        font-size: 0.85rem;
    }
    .tx-desc {
        font-size: 0.83rem;
    }
    .tx-amount {
        font-size: 0.85rem;
    }
    .filter-tab {
        padding: 4px 8px;
        font-size: 0.65rem;
    }
    .modal {
        padding: 20px;
    }
    .modal-actions {
        flex-wrap: wrap;
    }
    .modal-btn {
        min-width: calc(50% - 4px);
    }
}
