:root {
    --primary: #f0961a;
    --primary-dark: #d57811;
    --bg-color: #f4f4f9;
    --card-bg: #ffffff;
    --text-main: #333333;
    --text-muted: #666666;
    --danger: #ff4d4d;
    --border-radius: 12px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #1a1a1a;
        --card-bg: #2d2d2d;
        --text-main: #e0e0e0;
        --text-muted: #aaaaaa;
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    padding-bottom: 40px;
}

.app-header {
    background-color: var(--card-bg);
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    font-size: 1.5rem;
    font-weight: 800;
}

h1 span {
    color: var(--primary);
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

h2,
h3 {
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.total-amount {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 1rem;
}

.chart-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.chart-legend {
    margin-top: 1rem;
    font-size: 0.9rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    background: var(--bg-color);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

/* Floating Action Buttons */
.fab {
    position: fixed;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 10px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 999;
}

.fab:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.4);
}

.fab:active {
    transform: scale(0.95);
}

.fab-primary {
    bottom: 160px;
    right: 20px;
    background-color: var(--primary);
    color: white;
}

.fab-tertiary {
    bottom: 90px;
    right: 20px;
    background-color: #10b981;
    color: white;
}

.fab-secondary {
    bottom: 20px;
    right: 20px;
    background-color: #666;
    color: white;
}

.fab .icon {
    width: 24px;
    height: 24px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #eee;
}

.modal-header h3 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--bg-color);
    color: var(--text-main);
}

.modal-body {
    padding: 1.5rem;
}

/* Form */
.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
}

input,
select {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    background: var(--bg-color);
    color: var(--text-main);
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(240, 150, 26, 0.2);
}

.btn-primary {
    width: 100%;
    background-color: var(--primary);
    color: white;
    padding: 0.8rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.2s;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
}

.btn-secondary {
    background-color: #666;
    color: white;
    padding: 0.6rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.3rem;
    transition: background 0.2s;
    white-space: nowrap;
}

.btn-secondary:hover {
    background-color: #555;
}

/* Category Management */
.category-add-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.category-add-form input {
    flex: 1;
}

.category-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.category-tag {
    background: var(--primary);
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.category-tag.default {
    background: var(--bg-color);
    color: var(--text-main);
    border: 1px solid #ddd;
}

.category-tag button {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 0;
    font-size: 1rem;
    line-height: 1;
    opacity: 0.7;
}

.category-tag button:hover {
    opacity: 1;
}

/* List */
.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.text-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: underline;
}

.text-btn.danger {
    color: var(--danger);
}

.transaction-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.transaction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem;
    background: var(--bg-color);
    border-radius: 8px;
    border-left: 4px solid var(--primary);
}

.t-info h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.t-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.t-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.t-amount {
    font-weight: 700;
    font-size: 1.1rem;
}

.edit-btn,
.delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.2rem;
}

.edit-btn:hover {
    color: var(--primary);
}

.delete-btn:hover {
    color: var(--danger);
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
    font-style: italic;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-main);
    padding: 0.5rem;
    border-radius: 50%;
}

.icon-btn:hover {
    background: var(--bg-color);
}

/* Category Breakdown */
.breakdown-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-color);
    border-radius: 8px;
    border-left: 4px solid var(--primary);
}

.breakdown-category {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.breakdown-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
}

.breakdown-info h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.breakdown-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.breakdown-amount {
    text-align: right;
}

.breakdown-total {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.breakdown-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.breakdown-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
    font-style: italic;
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
    .modal-content {
        width: 95%;
    }

    .fab-primary {
        bottom: 160px;
        right: 15px;
    }

    .fab-tertiary {
        bottom: 90px;
        right: 15px;
    }

    .fab-secondary {
        bottom: 20px;
        right: 15px;
    }
}