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

:root {
    /* ブラウン基調のカラーパレット */
    --primary-color: #8b5a3c;
    --primary-dark: #6d4c41;
    --secondary-color: #a67c52;
    --success-color: #7d6e3a;
    --danger-color: #a0522d;
    --warning-color: #d4a574;
    --income-color: #7d6e3a;
    --expense-color: #a0522d;
    --text-primary: #3e2723;
    --text-secondary: #795548;
    --bg-primary: #faf8f5;
    --bg-secondary: #ffffff;
    --border-color: #d7ccc8;
    --shadow-sm: 0 1px 2px 0 rgba(62, 39, 35, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(62, 39, 35, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(62, 39, 35, 0.15);
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

/* コンテナ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ヘッダー */
.header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 1.5rem 0;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo i {
    font-size: 2rem;
}

/* ボタン */
.btn {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
    font-family: 'Noto Sans JP', sans-serif;
}

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

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

/* メインコンテンツ */
.main-content {
    padding: 2rem 0;
    min-height: calc(100vh - 100px);
}

/* サマリーカード */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.summary-card {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1.5rem;
}

.card-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
}

.income-card .card-icon {
    background: rgba(16, 185, 129, 0.1);
    color: var(--income-color);
}

.expense-card .card-icon {
    background: rgba(239, 68, 68, 0.1);
    color: var(--expense-color);
}

.balance-card .card-icon {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
}

.card-content h3 {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.card-content .amount {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

/* カード */
.card {
    background: var(--bg-secondary);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.card-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.card-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

/* タブ */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    overflow-x: auto;
}

.tab-btn {
    padding: 0.875rem 1.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
    white-space: nowrap;
    font-family: 'Noto Sans JP', sans-serif;
}

.tab-btn:hover {
    background: var(--bg-primary);
}

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

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s;
}

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

/* フィルター・ソートセクション */
.filter-sort-section {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.filter-section {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.sort-section {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.sort-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.375rem;
    white-space: nowrap;
}

.filter-select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.875rem;
    background: white;
    cursor: pointer;
    font-family: 'Noto Sans JP', sans-serif;
}

/* 取引リスト */
.transactions-list {
    max-height: 600px;
    overflow-y: auto;
}

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

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

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

.transaction-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.transaction-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.transaction-icon.income {
    background: rgba(16, 185, 129, 0.1);
    color: var(--income-color);
}

.transaction-icon.expense {
    background: rgba(239, 68, 68, 0.1);
    color: var(--expense-color);
}

.transaction-details h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.transaction-details p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.transaction-amount {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.transaction-amount .amount {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
    min-width: 120px;
    display: inline-block;
    text-align: right;
}

.transaction-amount.income .amount {
    color: var(--income-color);
}

.transaction-amount.expense .amount {
    color: var(--expense-color);
}

.transaction-amount .date {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.transaction-actions {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.action-btn.delete {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

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

/* 予算リスト */
.budget-list {
    padding: 1.5rem;
}

.budget-item {
    margin-bottom: 1.5rem;
}

.budget-item:last-child {
    margin-bottom: 0;
}

.budget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.budget-category {
    font-weight: 600;
    font-size: 1rem;
}

.budget-amounts {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.budget-amounts .spent {
    color: var(--expense-color);
    font-weight: 600;
}

.progress-bar {
    height: 12px;
    background: var(--bg-primary);
    border-radius: 6px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s, background 0.3s;
    border-radius: 6px;
}

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

.progress-fill.danger {
    background: var(--danger-color);
}

/* 分析グリッド */
.analytics-grid {
    display: grid;
    gap: 1.5rem;
}

.chart-container {
    padding: 1.5rem;
    position: relative;
}

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

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

.modal-content {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s;
}

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

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

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.close-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-primary);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.close-btn:hover {
    background: var(--border-color);
}

.modal-form {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Noto Sans JP', sans-serif;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.radio-group {
    display: flex;
    gap: 1rem;
}

.radio-label {
    flex: 1;
    cursor: pointer;
}

.radio-label input[type="radio"] {
    display: none;
}

.radio-custom {
    display: block;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    transition: all 0.2s;
}

.radio-label input[type="radio"]:checked + .radio-custom.expense {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--expense-color);
    color: var(--expense-color);
}

.radio-label input[type="radio"]:checked + .radio-custom.income {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--income-color);
    color: var(--income-color);
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.form-actions .btn {
    flex: 1;
}

/* 音声入力セクション */
.voice-input-section {
    margin-bottom: 1.5rem;
    text-align: center;
}

.btn-voice {
    width: 100%;
    padding: 1.25rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.125rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    transition: all 0.3s;
    font-family: 'Noto Sans JP', sans-serif;
}

.btn-voice:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-voice.listening {
    background: linear-gradient(135deg, var(--danger-color), #dc2626);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.btn-voice i {
    font-size: 1.5rem;
}

.voice-status {
    margin-top: 0.75rem;
    min-height: 24px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.voice-status.listening {
    color: var(--danger-color);
    font-weight: 600;
}

.voice-status.success {
    color: var(--success-color);
    font-weight: 600;
}

.voice-status.error {
    color: var(--danger-color);
}

.voice-help {
    margin-top: 0.5rem;
}

.voice-help small {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.form-divider {
    text-align: center;
    margin: 1.5rem 0;
    position: relative;
}

.form-divider::before,
.form-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: var(--border-color);
}

.form-divider::before {
    left: 0;
}

.form-divider::after {
    right: 0;
}

.form-divider span {
    background: white;
    padding: 0 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* カテゴリ管理 */
.categories-container {
    padding: 1.5rem;
}

.categories-section {
    margin-bottom: 2rem;
}

.categories-section:last-child {
    margin-bottom: 0;
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.category-list {
    display: grid;
    gap: 0.75rem;
}

.category-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--bg-primary);
    border-radius: 10px;
    transition: all 0.2s;
}

.category-item:hover {
    background: var(--border-color);
}

.category-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.category-icon-badge {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: white;
}

.category-details h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.category-details p {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

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

.category-actions .action-btn {
    width: 36px;
    height: 36px;
}

.action-btn.edit {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
}

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

/* カラーピッカー */
.color-picker {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.color-picker input[type="color"] {
    width: 60px;
    height: 40px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
}

.color-preview {
    flex: 1;
    height: 40px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.form-help {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* 定期取引 */
.recurring-info {
    padding: 1rem 1.5rem;
    background: rgba(139, 90, 60, 0.05);
    border-left: 4px solid var(--primary-color);
    margin: 0 1.5rem 1.5rem;
    border-radius: 0 8px 8px 0;
}

.info-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.info-text i {
    color: var(--primary-color);
}

.recurring-list {
    padding: 1.5rem;
}

.recurring-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem;
    background: var(--bg-primary);
    border-radius: 10px;
    margin-bottom: 1rem;
    transition: all 0.2s;
}

.recurring-item:hover {
    background: var(--border-color);
}

.recurring-item:last-child {
    margin-bottom: 0;
}

.recurring-info-section {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.recurring-icon-badge {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.recurring-icon-badge.income {
    background: rgba(125, 110, 58, 0.1);
    color: var(--income-color);
}

.recurring-icon-badge.expense {
    background: rgba(160, 82, 45, 0.1);
    color: var(--expense-color);
}

.recurring-details h4 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.recurring-details p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.125rem;
}

.recurring-amount-section {
    text-align: right;
    margin-right: 1rem;
}

.recurring-amount-section .amount {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    font-variant-numeric: tabular-nums;
}

.recurring-amount-section.income .amount {
    color: var(--income-color);
}

.recurring-amount-section.expense .amount {
    color: var(--expense-color);
}

.recurring-day {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.recurring-actions {
    display: flex;
    gap: 0.5rem;
}

.recurring-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toggle-switch {
    position: relative;
    width: 48px;
    height: 26px;
    background: var(--border-color);
    border-radius: 13px;
    cursor: pointer;
    transition: background 0.3s;
}

.toggle-switch.active {
    background: var(--primary-color);
}

.toggle-slider {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s;
}

.toggle-switch.active .toggle-slider {
    transform: translateX(22px);
}

/* ローディング・空状態 */
.loading,
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 3rem;
    color: var(--border-color);
    margin-bottom: 1rem;
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    .header .container {
        flex-direction: column;
        gap: 1rem;
    }

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

    .card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .transaction-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .transaction-amount {
        text-align: left;
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .tabs {
        flex-direction: column;
    }

    .tab-btn {
        width: 100%;
        justify-content: center;
    }

    .filter-section {
        width: 100%;
    }

    .filter-select {
        flex: 1;
    }
}

@media (max-width: 480px) {
    .logo {
        font-size: 1.5rem;
    }

    .summary-card {
        flex-direction: column;
        text-align: center;
    }

    .modal-content {
        max-width: 100%;
        height: 100vh;
        border-radius: 0;
    }
}
