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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans',
                 'Hiragino Kaku Gothic ProN', 'Meiryo', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    padding: 36px 40px;
}

h1 {
    text-align: center;
    font-size: 1.55rem;
    color: #1a202c;
    margin-bottom: 4px;
}
.subtitle {
    text-align: center;
    font-size: 0.85rem;
    color: #718096;
    margin-bottom: 22px;
}

/* ── 償却方法タブ ── */
.method-tabs {
    display: flex;
    gap: 0;
    border: 2px solid #667eea;
    border-radius: 8px;
    overflow: hidden;
    width: fit-content;
    margin-bottom: 10px;
}
.method-tab {
    padding: 8px 22px;
    background: white;
    color: #667eea;
    border: none;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    min-width: auto;
    transform: none;
}
.method-tab:hover { background: #eef0ff; transform: none; }
.method-tab.active { background: #667eea; color: white; }

.method-note {
    font-size: 0.8rem;
    color: #718096;
    line-height: 1.6;
    margin-bottom: 20px;
    padding: 10px 14px;
    background: #f7f8fa;
    border-radius: 6px;
}

/* ── 入力エリア ── */
.input-section {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding: 20px 22px;
    background: #f8f9fa;
    border-radius: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
    min-width: 160px;
}

label {
    font-size: 0.8rem;
    font-weight: 700;
    color: #4a5568;
    letter-spacing: 0.04em;
    display: flex;
    align-items: center;
    gap: 6px;
}
.optional {
    font-size: 0.7rem;
    font-weight: 400;
    color: #a0aec0;
    background: #edf2f7;
    padding: 1px 6px;
    border-radius: 3px;
}
.input-hint {
    font-size: 0.73rem;
    color: #a0aec0;
}

input[type="text"],
input[type="number"] {
    padding: 9px 11px;
    border: 2px solid #dde1e7;
    border-radius: 7px;
    font-size: 0.95rem;
    background: white;
    color: #1a202c;
    transition: border-color 0.2s, box-shadow 0.2s;
    -moz-appearance: textfield;
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }
input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102,126,234,0.15);
}

select {
    padding: 9px 11px;
    border: 2px solid #dde1e7;
    border-radius: 7px;
    font-size: 0.95rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}
select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102,126,234,0.15);
}

/* ── エラー ── */
.error-message {
    background: #fff5f5;
    color: #c53030;
    padding: 11px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    border-left: 4px solid #fc8181;
    font-size: 0.875rem;
}

/* ── 5か年サマリーカード ── */
.summary-card {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-radius: 12px;
    padding: 20px 24px;
    margin-bottom: 24px;
}
.summary-eyebrow {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    opacity: 0.75;
    margin-bottom: 14px;
}
.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}
.summary-item {
    background: rgba(255,255,255,0.12);
    border-radius: 8px;
    padding: 12px 14px;
}
.summary-label {
    font-size: 0.75rem;
    opacity: 0.8;
    margin-bottom: 6px;
    line-height: 1.4;
}
.summary-value {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.01em;
}

/* ── テーブルヘッダー ── */
.result-section { }
.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 10px;
}
.table-header h2 { font-size: 1.05rem; color: #1a202c; }

.table-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* 5年/全期間トグル */
.view-toggle {
    display: flex;
    border: 1.5px solid #cbd5e0;
    border-radius: 7px;
    overflow: hidden;
}
.view-btn {
    padding: 6px 14px;
    background: white;
    color: #4a5568;
    border: none;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    min-width: auto;
    transform: none;
    transition: background 0.15s, color 0.15s;
}
.view-btn:hover { background: #edf2f7; transform: none; }
.view-btn.active { background: #667eea; color: white; }
.view-btn + .view-btn { border-left: 1.5px solid #cbd5e0; }

.copy-btn {
    padding: 7px 16px;
    background: #38a169;
    color: white;
    border: none;
    border-radius: 7px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    min-width: auto;
    transition: background 0.2s;
    transform: none;
}
.copy-btn:hover { background: #2f855a; transform: none; }

/* ── テーブル ── */
#tableContainer { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
thead tr { background: #667eea; color: white; }
th {
    padding: 11px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    letter-spacing: 0.03em;
}
td { padding: 10px 14px; border-bottom: 1px solid #f0f0f0; }

/* 5か年計画期間（ハイライト） */
.row-plan { background: #fafbff; }
.row-plan .td-year { font-weight: 700; color: #3730a3; }
.row-plan .td-period { color: #4338ca; font-weight: 600; }

/* 全期間の5年超 */
.row-outer { }
.row-outer td { color: #9aa0ac; }

.td-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}
.yen { font-size: 0.75em; color: inherit; opacity: 0.7; margin-left: 1px; }
.td-year { white-space: nowrap; }
.td-period { white-space: nowrap; color: #4a5568; }

tbody tr:hover { background: #f0f4ff !important; }

/* 全期間表示ボタン行 */
.row-more td {
    text-align: center;
    padding: 10px;
    border-bottom: none;
    background: #f7f8fa;
}
.btn-show-all {
    background: none;
    border: 1.5px solid #cbd5e0;
    color: #4a5568;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 6px 18px;
    border-radius: 6px;
    cursor: pointer;
    min-width: auto;
    transform: none;
    transition: background 0.15s;
}
.btn-show-all:hover { background: #edf2f7; transform: none; }

/* ── レスポンシブ ── */
@media (max-width: 640px) {
    .container { padding: 20px 16px; }
    h1 { font-size: 1.25rem; }
    .summary-grid { grid-template-columns: 1fr 1fr; }
    .summary-grid .summary-item:last-child { grid-column: span 2; }
    .input-section { gap: 12px; }
    .input-group { min-width: 140px; }
    .table-header { flex-direction: column; align-items: flex-start; }
}
