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

:root {
    --primary-color: #1976D2;
    --secondary-color: #4CAF50;
    --danger-color: #f44336;
    --warning-color: #FF9800;
    --background: #f5f7fa;
    --surface: #ffffff;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --border-color: #e0e6ed;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 16px rgba(0,0,0,0.15);
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ヘッダー */
.header {
    background: var(--surface);
    padding: 20px 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.language-selector {
    padding: 8px 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.language-selector:hover {
    border-color: var(--primary-color);
}

/* 統計カード */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--surface);
    padding: 25px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.stat-card.income {
    border-left: 4px solid var(--secondary-color);
}

.stat-card.expense {
    border-left: 4px solid var(--danger-color);
}

.stat-card.balance {
    border-left: 4px solid var(--primary-color);
}

.stat-card.budget {
    border-left: 4px solid var(--warning-color);
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.budget-progress {
    margin-top: 15px;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.budget-progress-bar {
    height: 100%;
    background: var(--secondary-color);
    transition: width 0.3s ease;
    border-radius: 4px;
}

.budget-progress-bar.warning {
    background: var(--warning-color);
}

.budget-progress-bar.over-budget {
    background: var(--danger-color);
}

/* タブ */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    background: var(--surface);
    padding: 10px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.tab-button {
    flex: 1;
    padding: 12px 20px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.3s ease;
}

.tab-button:hover {
    background: var(--background);
}

.tab-button.active {
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-sm);
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* フォーム */
.input-form {
    background: var(--surface);
    padding: 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 15px;
    transition: all 0.3s ease;
    background: var(--surface);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
}

.toggle-buttons {
    display: flex;
    gap: 10px;
}

.toggle-btn {
    flex: 1;
    padding: 12px 20px;
    border: 2px solid var(--border-color);
    background: var(--surface);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

.toggle-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* ボタン */
.btn {
    padding: 12px 30px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: #1565C0;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--surface);
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

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

/* リスト */
.list-controls {
    background: var(--surface);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.filter-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    flex: 1;
}

.filter-select,
.filter-input {
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--surface);
}

.transaction-list {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.transaction-item {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.3s ease;
}

.transaction-item:hover {
    background: var(--background);
}

.transaction-item:last-child {
    border-bottom: none;
}

.transaction-info {
    flex: 1;
}

.transaction-main {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 5px;
}

.transaction-category {
    background: var(--primary-color);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.transaction-item.income .transaction-category {
    background: var(--secondary-color);
}

.transaction-description {
    color: var(--text-primary);
    font-size: 15px;
}

.transaction-date {
    color: var(--text-secondary);
    font-size: 13px;
}

.transaction-amount {
    display: flex;
    align-items: center;
    gap: 15px;
}

.transaction-amount span {
    font-size: 18px;
    font-weight: 600;
}

.positive {
    color: var(--secondary-color);
}

.negative {
    color: var(--danger-color);
}

.delete-btn {
    padding: 6px 12px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.delete-btn:hover {
    background: #d32f2f;
}

.empty-state {
    padding: 60px 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 16px;
}

/* レポート */
.report-controls {
    background: var(--surface);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 30px;
    display: flex;
    gap: 15px;
    align-items: center;
}

.report-select,
.report-input {
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--surface);
}

.charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 30px;
    margin-bottom: 30px;
}

.chart-wrapper {
    background: var(--surface);
    padding: 25px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.chart-wrapper h3 {
    margin-bottom: 20px;
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
}

.chart-wrapper canvas {
    max-height: 300px;
}

.category-summary {
    background: var(--surface);
    padding: 25px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.category-summary h3 {
    margin-bottom: 20px;
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
}

.summary-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: var(--background);
    border-radius: var(--radius-sm);
    transition: all 0.3s ease;
}

.summary-item:hover {
    transform: translateX(5px);
}

.summary-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.summary-category {
    font-weight: 500;
}

.summary-percentage {
    background: var(--primary-color);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.summary-amount {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

/* 予算 */
.budget-form {
    background: var(--surface);
    padding: 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.budget-form h3 {
    margin: 30px 0 20px;
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
}

.category-budgets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.budget-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.budget-item label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.budget-item input {
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--surface);
}

.budget-alerts {
    margin-top: 30px;
}

.alert {
    padding: 15px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(-20px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.alert-warning {
    background: #FFF3E0;
    color: #E65100;
    border-left: 4px solid var(--warning-color);
}

.alert-danger {
    background: #FFEBEE;
    color: #B71C1C;
    border-left: 4px solid var(--danger-color);
}

/* 通知 */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--primary-color);
    color: white;
    padding: 15px 25px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    transform: translateX(400px);
    transition: transform 0.3s ease;
    z-index: 1000;
}

.notification.show {
    transform: translateX(0);
}

/* レスポンシブ */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .app-title {
        font-size: 24px;
    }

    .stats-cards {
        grid-template-columns: 1fr;
    }

    .tabs {
        flex-direction: column;
    }

    .tab-button {
        width: 100%;
    }

    .input-form {
        padding: 20px;
    }

    .list-controls {
        flex-direction: column;
    }

    .filter-group {
        width: 100%;
    }

    .filter-select,
    .filter-input {
        width: 100%;
    }

    .transaction-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .transaction-amount {
        width: 100%;
        justify-content: space-between;
    }

    .charts-container {
        grid-template-columns: 1fr;
    }

    .chart-wrapper {
        padding: 20px;
    }

    .category-budgets {
        grid-template-columns: 1fr;
    }

    .notification {
        right: 10px;
        left: 10px;
        transform: translateY(-100px);
    }

    .notification.show {
        transform: translateY(0);
    }
}

@media (max-width: 480px) {
    .app-title {
        font-size: 20px;
    }

    .stat-value {
        font-size: 24px;
    }

    .toggle-buttons {
        flex-direction: column;
    }

    .report-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .report-select,
    .report-input {
        width: 100%;
    }
}

/* ダークモード対応 */
@media (prefers-color-scheme: dark) {
    :root {
        --background: #1a1d23;
        --surface: #22262d;
        --text-primary: #e4e6ea;
        --text-secondary: #b0b3b8;
        --border-color: #3a3d44;
    }

    .form-group input,
    .form-group select,
    .filter-select,
    .filter-input,
    .report-select,
    .report-input,
    .budget-item input {
        background: var(--surface);
        color: var(--text-primary);
    }

    .toggle-btn {
        background: var(--surface);
        color: var(--text-secondary);
    }

    .summary-item {
        background: #2c3038;
    }

    .alert-warning {
        background: #3d2f00;
        color: #ffb74d;
    }

    .alert-danger {
        background: #4a0e0e;
        color: #ef5350;
    }
}

/* プリント対応 */
@media print {
    .header-controls,
    .tabs,
    .delete-btn,
    .btn,
    .list-controls,
    .report-controls {
        display: none;
    }

    .container {
        max-width: 100%;
    }

    .tab-content {
        display: block !important;
        page-break-after: always;
    }

    .transaction-item {
        page-break-inside: avoid;
    }
}