/* ==================== */
/* グローバル設定 */
/* ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --secondary-color: #7c3aed;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #06b6d4;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
}

/* ==================== */
/* コンテナ */
/* ==================== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    background: var(--card-bg);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

/* ==================== */
/* ヘッダー */
/* ==================== */
.header {
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

.header h1 {
    font-size: 2rem;
    margin-bottom: 10px;
    font-weight: 700;
}

.header .subtitle {
    font-size: 1rem;
    opacity: 0.9;
    font-weight: 300;
}

/* ==================== */
/* タブナビゲーション */
/* ==================== */
.tab-nav {
    display: flex;
    background: #f1f5f9;
    padding: 10px;
    gap: 5px;
    overflow-x: auto;
    border-bottom: 2px solid var(--border-color);
}

.tab-button {
    flex: 1;
    min-width: 150px;
    padding: 12px 20px;
    background: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    white-space: nowrap;
}

.tab-button:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

.tab-button i {
    margin-right: 8px;
}

/* ==================== */
/* タブコンテンツ */
/* ==================== */
.tab-content {
    display: none;
    padding: 30px;
    animation: fadeIn 0.3s ease;
}

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

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

/* ==================== */
/* モード切替 */
/* ==================== */
.mode-switcher {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    background: var(--bg-color);
    padding: 5px;
    border-radius: 10px;
}

.mode-btn {
    flex: 1;
    padding: 12px 20px;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.3s ease;
}

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

.mode-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

/* ==================== */
/* フォームセクション */
/* ==================== */
.form-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: var(--shadow-sm);
}

.form-section h2 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
}

.form-section h2 i {
    margin-right: 10px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select {
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: white;
}

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

.form-group small {
    margin-top: 5px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.form-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    cursor: pointer;
}

.hidden {
    display: none !important;
}

/* ==================== */
/* ボタン */
/* ==================== */
.action-buttons {
    display: flex;
    gap: 15px;
    margin: 30px 0;
    flex-wrap: wrap;
}

.btn {
    flex: 1;
    min-width: 150px;
    padding: 14px 28px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: var(--shadow-sm);
}

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

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

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

.btn-primary:hover {
    background: #1d4ed8;
}

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

.btn-secondary:hover {
    background: #475569;
}

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

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

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

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

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

.btn-save:hover {
    background: #0891b2;
}

/* ==================== */
/* 結果セクション */
/* ==================== */
.results-section {
    background: var(--bg-color);
    border-radius: 12px;
    padding: 30px;
    margin-top: 30px;
    box-shadow: var(--shadow-md);
}

.results-section h3 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.result-card {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--primary-color);
}

.result-card.warning {
    border-left-color: var(--warning-color);
    background: #fffbeb;
}

.result-card.danger {
    border-left-color: var(--danger-color);
    background: #fef2f2;
}

.result-card.success {
    border-left-color: var(--success-color);
    background: #f0fdf4;
}

.result-card h4 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.result-card .value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
}

.result-card.warning .value {
    color: var(--warning-color);
}

.result-card.danger .value {
    color: var(--danger-color);
}

.result-card.success .value {
    color: var(--success-color);
}

.result-card .unit {
    font-size: 1rem;
    font-weight: 400;
    margin-left: 5px;
}

.result-card .description {
    margin-top: 10px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ==================== */
/* アラート */
/* ==================== */
.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
}

.alert i {
    font-size: 1.2rem;
}

.alert-warning {
    background: #fffbeb;
    border: 1px solid #fbbf24;
    color: #92400e;
}

.alert-danger {
    background: #fef2f2;
    border: 1px solid #f87171;
    color: #991b1b;
}

.alert-info {
    background: #eff6ff;
    border: 1px solid #60a5fa;
    color: #1e40af;
}

.alert-success {
    background: #f0fdf4;
    border: 1px solid #34d399;
    color: #065f46;
}

/* ==================== */
/* テーブル */
/* ==================== */
.table-wrapper {
    overflow-x: auto;
    margin-top: 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

table thead {
    background: var(--primary-color);
    color: white;
}

table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
}

table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

table tbody tr:hover {
    background: var(--bg-color);
}

table tbody tr:last-child td {
    border-bottom: none;
}

.table-controls {
    margin-bottom: 15px;
}

.table-controls label {
    font-weight: 500;
    color: var(--text-primary);
}

.table-controls select {
    margin-left: 10px;
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
}

/* ==================== */
/* 履歴カード */
/* ==================== */
.history-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

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

.history-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.history-card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-color);
}

.history-card-date {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.history-card-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.history-item {
    display: flex;
    flex-direction: column;
}

.history-item-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.history-item-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.history-actions {
    margin-top: 15px;
    display: flex;
    gap: 10px;
}

.history-actions button {
    padding: 8px 16px;
    font-size: 0.85rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

.btn-load:hover {
    background: #0891b2;
}

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

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

/* ==================== */
/* 諸費用設定テーブル */
/* ==================== */
.settings-table-wrapper {
    overflow-x: auto;
}

.settings-table {
    width: 100%;
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

.settings-table input[type="text"],
.settings-table input[type="number"],
.settings-table select {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.9rem;
}

.settings-table input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* ==================== */
/* 情報テキスト */
/* ==================== */
.info-text {
    background: #eff6ff;
    border-left: 4px solid var(--info-color);
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 6px;
    color: #1e40af;
}

.info-text i {
    margin-right: 10px;
}

/* ==================== */
/* フッター */
/* ==================== */
.footer {
    background: var(--text-primary);
    color: white;
    text-align: center;
    padding: 20px;
    margin-top: 30px;
}

.footer p {
    font-size: 0.9rem;
    opacity: 0.8;
}

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

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

    .tab-nav {
        flex-wrap: nowrap;
        overflow-x: auto;
    }

    .tab-button {
        min-width: 120px;
        font-size: 0.85rem;
        padding: 10px 15px;
    }

    .tab-content {
        padding: 20px 15px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

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

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

    .btn {
        width: 100%;
    }

    .mode-switcher {
        flex-direction: column;
    }

    .result-card .value {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.2rem;
    }

    .header .subtitle {
        font-size: 0.85rem;
    }

    .form-section h2 {
        font-size: 1.1rem;
    }

    .results-section h3 {
        font-size: 1.2rem;
    }
}

/* ==================== */
/* プリント用スタイル */
/* ==================== */
@media print {
    body {
        background: white;
        padding: 0;
    }

    .tab-nav,
    .action-buttons,
    .footer {
        display: none;
    }

    .container {
        box-shadow: none;
    }

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