/* リセットとベーススタイル */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

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

/* ヘッダー */
header {
    background: linear-gradient(135deg, #ff6b6b 0%, #ff8e53 100%);
    color: white;
    padding: 30px;
    border-radius: 20px;
    margin-bottom: 30px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 28px;
    margin-bottom: 15px;
    text-align: center;
}

.balance-display {
    text-align: center;
}

.balance-label {
    display: block;
    font-size: 14px;
    opacity: 0.9;
}

.balance-amount {
    font-size: 36px;
    font-weight: bold;
}

/* 入力セクション */
.input-section {
    background: white;
    padding: 30px;
    border-radius: 20px;
    margin-bottom: 30px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.input-section h2 {
    font-size: 20px;
    margin-bottom: 20px;
    color: #333;
}

/* 収支タイプ選択 */
.transaction-type {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.type-btn {
    flex: 1;
    padding: 12px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 10px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
}

.type-btn.active {
    background: #ff6b6b;
    color: white;
    border-color: #ff6b6b;
}

.type-btn:not(.active):hover {
    background: #f5f5f5;
}

/* フォームグループ */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #ff6b6b;
}

/* カテゴリーグリッド */
.category-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.category-btn {
    padding: 10px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    font-size: 12px;
}

.category-btn.selected {
    background: #ff6b6b;
    color: white;
    border-color: #ff6b6b;
}

.category-btn:not(.selected):hover {
    background: #f5f5f5;
}

.category-icon {
    font-size: 24px;
    display: block;
    margin-bottom: 4px;
}

.subcategory-arrow {
    font-size: 12px;
    position: absolute;
    right: 8px;
    top: 8px;
    opacity: 0.7;
}

.category-btn {
    position: relative;
}

.category-btn.back-btn {
    grid-column: span 4;
    background: #f5f5f5;
    border-color: #ccc;
}

.category-btn.back-btn:hover {
    background: #e9e9e9;
}

/* 送信ボタン */
.submit-btn {
    width: 100%;
    padding: 15px;
    background: #ff6b6b;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s;
}

.submit-btn:hover {
    background: #ff5252;
}

/* 月選択 */
.month-selector {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
}

.month-selector button {
    padding: 10px 15px;
    background: white;
    border: 2px solid #ddd;
    border-radius: 10px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s;
}

.month-selector button:hover {
    background: #f5f5f5;
}

#currentMonth {
    font-size: 20px;
    font-weight: bold;
}

/* 集計セクション */
.summary-section {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.summary-card {
    background: white;
    padding: 20px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.summary-card h3 {
    font-size: 16px;
    color: #666;
    margin-bottom: 10px;
}

.amount {
    font-size: 24px;
    font-weight: bold;
}

.amount.income {
    color: #4caf50;
}

.amount.expense {
    color: #ff6b6b;
}

.amount.balance {
    color: #333;
}

/* グラフセクション */
.chart-section {
    background: white;
    padding: 30px;
    border-radius: 20px;
    margin-bottom: 30px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.chart-section h2 {
    font-size: 20px;
    margin-bottom: 20px;
    color: #333;
}

#chartContainer {
    max-width: 400px;
    margin: 0 auto;
}

/* 履歴セクション */
.history-section {
    background: white;
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.history-section h2 {
    font-size: 20px;
    margin-bottom: 20px;
    color: #333;
}

.transaction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid #eee;
    transition: background 0.3s;
}

.transaction-item:hover {
    background: #f9f9f9;
}

.transaction-info {
    flex: 1;
}

.transaction-date {
    font-size: 12px;
    color: #999;
}

.transaction-category {
    font-size: 14px;
    color: #666;
}

.transaction-memo {
    font-size: 12px;
    color: #999;
}

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

.transaction-amount.income {
    color: #4caf50;
}

.transaction-amount.expense {
    color: #ff6b6b;
}

.delete-btn {
    padding: 5px 10px;
    background: #ff6b6b;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    margin-left: 10px;
}

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

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

    header {
        padding: 20px;
    }

    header h1 {
        font-size: 24px;
    }

    .balance-amount {
        font-size: 28px;
    }

    .category-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .summary-section {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .summary-card {
        padding: 15px;
    }
}