/* ===================================
   Modern Professional Design System
   =================================== */

/* カスタムプロパティ（CSS変数） */
:root {
    /* Primary Colors - 洗練されたブルー系 */
    --primary-50: #f0f7ff;
    --primary-100: #e0efff;
    --primary-200: #b9ddff;
    --primary-300: #7cc4ff;
    --primary-400: #36a9ff;
    --primary-500: #0891ff;
    --primary-600: #0072e5;
    --primary-700: #005bb5;
    --primary-800: #004a94;
    --primary-900: #003d7a;
    
    /* Neutral Colors */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    /* Semantic Colors */
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --error: #ef4444;
    --error-light: #fee2e2;
    --info: #3b82f6;
    --info-light: #dbeafe;
    
    /* Shadows */
    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans JP', sans-serif;
    background: linear-gradient(135deg, var(--gray-50) 0%, var(--primary-50) 100%);
    color: var(--gray-900);
    line-height: 1.6;
    min-height: 100vh;
    padding: 2rem 1rem;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

/* ===================================
   ヘッダー - プロフェッショナル
   =================================== */
.header {
    background: linear-gradient(135deg, var(--primary-700) 0%, var(--primary-900) 100%);
    color: white;
    padding: 3rem 2.5rem;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 40%;
    height: 100%;
    background: url('data:image/svg+xml,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><circle cx="50" cy="50" r="40" fill="rgba(255,255,255,0.05)"/></svg>');
    opacity: 0.3;
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    position: relative;
    letter-spacing: -0.02em;
}

.header h1 i {
    margin-right: 0.75rem;
    opacity: 0.9;
}

.subtitle {
    font-size: 1rem;
    opacity: 0.95;
    font-weight: 400;
    position: relative;
}

/* ===================================
   メインコンテンツ
   =================================== */
.main-content {
    padding: 2.5rem;
}

section {
    margin-bottom: 2.5rem;
}

section h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

section h2 i {
    color: var(--primary-600);
}

/* ===================================
   フォームグループ - モダン
   =================================== */
.form-group {
    background: var(--gray-50);
    padding: 2rem;
    border-radius: var(--radius-xl);
    margin-bottom: 1.5rem;
    border: 1px solid var(--gray-200);
    transition: all var(--transition-base);
}

.form-group:hover {
    border-color: var(--primary-200);
    box-shadow: var(--shadow-sm);
}

.form-group h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-group h3 i {
    color: var(--primary-600);
    font-size: 1rem;
}

/* ===================================
   入力フィールド - 洗練された
   =================================== */
.input-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
}

.input-field {
    position: relative;
}

.input-field label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--gray-700);
    font-size: 0.875rem;
    letter-spacing: 0.01em;
}

.input-field input,
.input-field select {
    width: 100%;
    padding: 0.75rem 3.5rem 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
    background: white;
    color: var(--gray-900);
    font-weight: 500;
}

.input-field input:focus,
.input-field select:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px var(--primary-100);
}

.input-field input:hover,
.input-field select:hover {
    border-color: var(--primary-400);
}

.input-field .unit {
    position: absolute;
    right: 1rem;
    top: 2.25rem;
    color: var(--gray-500);
    font-weight: 600;
    font-size: 0.875rem;
    pointer-events: none;
}

.input-field small {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.75rem;
    color: var(--gray-500);
}

.take-home-preview {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--success);
    font-weight: 600;
    min-height: 1.25rem;
    padding: 0.25rem 0;
}

/* ===================================
   ボタン - モダンで洗練
   =================================== */
.button-group {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.btn {
    padding: 0.875rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-sm);
    letter-spacing: 0.01em;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-700) 100%);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-700) 0%, var(--primary-800) 100%);
}

.btn-secondary {
    background: var(--gray-600);
    color: white;
}

.btn-secondary:hover {
    background: var(--gray-700);
}

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

.btn-success:hover {
    background: #059669;
}

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

.btn-pdf:hover {
    background: #dc2626;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ===================================
   追加支出項目
   =================================== */
.add-expense-btn-wrapper {
    margin-top: 1.25rem;
    text-align: center;
}

.btn-add-expense {
    padding: 0.75rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    border: 2px dashed var(--primary-400);
    background: var(--primary-50);
    color: var(--primary-700);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-add-expense:hover {
    background: var(--primary-100);
    border-color: var(--primary-600);
    border-style: solid;
}

.additional-expense-item {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    margin-top: 1rem;
    padding: 1.25rem;
    background: white;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    transition: all var(--transition-base);
}

.additional-expense-item:hover {
    border-color: var(--primary-300);
    box-shadow: var(--shadow-sm);
}

.additional-expense-item .input-field {
    flex: 1;
    position: relative;
}

.additional-expense-item .input-field input {
    padding-right: 4.5rem;
}

.additional-expense-item .input-field .unit {
    position: absolute;
    right: 1rem;
    top: 2.25rem;
    color: var(--gray-500);
    font-weight: 600;
    font-size: 0.875rem;
    pointer-events: none;
}

.additional-expense-item .btn-remove-expense {
    padding: 0.75rem 1rem;
    background: var(--error);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
}

.additional-expense-item .btn-remove-expense:hover {
    background: #dc2626;
    transform: scale(1.05);
}

/* ===================================
   折りたたみセクション
   =================================== */
.collapsible {
    border: 2px solid var(--primary-200);
}

.collapsible-header {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-700) 100%);
    margin: -2rem -2rem 1.5rem -2rem;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    transition: all var(--transition-base);
}

.collapsible-header:hover {
    background: linear-gradient(135deg, var(--primary-700) 0%, var(--primary-800) 100%);
}

.collapsible-header h3 {
    color: white;
    margin: 0;
    padding: 0;
    border: none;
    font-size: 1rem;
}

.collapsible-header .toggle-icon {
    color: white;
    font-size: 1.125rem;
    transition: transform var(--transition-base);
}

.collapsible-content {
    padding-top: 0;
}

.person-deductions {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    margin-bottom: 1.25rem;
    border: 2px solid var(--gray-200);
}

.person-deductions h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.person-deductions h4 i {
    color: var(--primary-600);
}

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

.summary-card {
    background: linear-gradient(135deg, var(--gray-50) 0%, white 100%);
    padding: 1.75rem;
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    gap: 1.25rem;
    border: 2px solid var(--gray-200);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.summary-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, rgba(0,0,0,0.02) 0%, transparent 70%);
}

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-300);
}

.summary-card.primary {
    background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-700) 100%);
    color: white;
    border-color: var(--primary-700);
}

.summary-card.primary .card-icon,
.summary-card.primary .card-content h4,
.summary-card.primary .card-content .value,
.summary-card.primary .card-content .note {
    color: white;
}

.card-icon {
    font-size: 2.5rem;
    opacity: 0.9;
}

.summary-card:not(.primary) .card-icon {
    color: var(--primary-600);
}

.card-content {
    flex: 1;
}

.card-content h4 {
    font-size: 0.8125rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.card-content .value {
    font-size: 1.875rem;
    font-weight: 800;
    color: var(--gray-900);
    margin-bottom: 0.25rem;
    letter-spacing: -0.02em;
}

.card-content .note {
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* ===================================
   詳細結果テーブル
   =================================== */
.detail-result {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.detail-column h3 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.detail-column h3 i {
    color: var(--primary-600);
}

.result-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--gray-200);
}

.result-table tr {
    border-bottom: 1px solid var(--gray-100);
    transition: background var(--transition-fast);
}

.result-table tr:hover {
    background: var(--gray-50);
}

.result-table td {
    padding: 0.875rem 1rem;
    font-size: 0.9375rem;
}

.result-table td:first-child {
    color: var(--gray-700);
    font-weight: 500;
}

.result-table .amount {
    text-align: right;
    font-weight: 700;
    color: var(--gray-900);
    font-variant-numeric: tabular-nums;
}

.result-table .total-row {
    background: var(--primary-50);
    border-top: 2px solid var(--primary-200);
    border-bottom: 2px solid var(--primary-200);
}

.result-table .total-row td {
    font-weight: 700;
    color: var(--primary-900);
}

/* ===================================
   チャート
   =================================== */
.chart-container {
    background: var(--gray-50);
    padding: 2rem;
    border-radius: var(--radius-xl);
    border: 2px solid var(--gray-200);
}

/* ===================================
   履歴
   =================================== */
.history-list {
    display: grid;
    gap: 1.25rem;
}

.history-item {
    background: var(--gray-50);
    padding: 1.5rem;
    border-radius: var(--radius-xl);
    border: 2px solid var(--gray-200);
    transition: all var(--transition-base);
}

.history-item:hover {
    border-color: var(--primary-300);
    box-shadow: var(--shadow-sm);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--gray-300);
}

.history-date {
    font-size: 0.875rem;
    color: var(--gray-600);
    font-weight: 600;
}

.history-data {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.history-data-item {
    display: flex;
    justify-content: space-between;
}

.history-data-item .label {
    color: var(--gray-600);
    font-size: 0.875rem;
}

.history-data-item .value {
    font-weight: 700;
    color: var(--gray-900);
    font-size: 0.875rem;
}

.history-actions {
    display: flex;
    gap: 0.75rem;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    font-weight: 600;
}

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

.btn-load:hover {
    background: var(--primary-700);
}

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

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

/* ===================================
   フッター
   =================================== */
.footer {
    background: var(--gray-900);
    color: white;
    text-align: center;
    padding: 1.5rem;
    font-size: 0.875rem;
}

/* ===================================
   レスポンシブ
   =================================== */
@media (max-width: 768px) {
    body {
        padding: 1rem 0.5rem;
    }

    .header {
        padding: 2rem 1.5rem;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .main-content {
        padding: 1.5rem;
    }

    .input-row {
        grid-template-columns: 1fr;
    }

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

    .detail-result {
        grid-template-columns: 1fr;
    }

    .button-group {
        flex-direction: column;
    }

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

/* ===================================
   アニメーション
   =================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-section {
    animation: fadeIn 0.5s ease-out;
}
