/* ================================================
   수익률분석 전용 스타일 (반응형)
   ================================================ */
.profit-container { max-width: 1100px; margin: 0 auto; padding: 10px 16px 40px; }

/* ─── 입력 폼 ─── */
.profit-form .section-card {
    background: #fff; border: 1px solid #e0e0e0; border-radius: 12px;
    padding: 20px; margin-bottom: 20px;
}
.profit-form .section-title {
    font-size: 1.05em; font-weight: 700; color: #1b523c;
    margin: 0 0 16px; padding-bottom: 8px; border-bottom: 2px solid #3cb371;
    display: flex; align-items: center; gap: 8px;
}

/* 그리드: PC 3열, 태블릿 2열, 모바일 1열 */
.profit-form .field-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px 16px;
}
.profit-form .field-group {
    display: flex; flex-direction: column;
    padding-bottom: 20px; /* 한글금액 표시 공간 확보 */
}
.profit-form .field-group.full-width { grid-column: 1 / -1; }

.profit-form .field-label {
    font-size: 0.85em; color: #555; margin-bottom: 4px; font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.profit-form .field-row {
    display: flex; align-items: center; gap: 6px;
}
.profit-form .field-row input {
    flex: 1; min-width: 0; /* 오버플로 방지 */
    padding: 10px 10px; border: 1px solid #ccc; border-radius: 6px;
    font-size: 0.95em; background: #fafafa; text-align: right;
    box-sizing: border-box;
}
.profit-form .field-row input:focus { border-color: #3cb371; background: #fff; outline: none; }
.profit-form .field-unit { font-size: 0.85em; color: #888; min-width: 20px; flex-shrink: 0; }
.profit-form .field-row input.auto-calc { background: #e8f5e9; color: #2e7d32; font-weight: 600; }

/* 투자계획 라디오 */
.invest-type-group { display: flex; gap: 10px; flex-wrap: wrap; }
.invest-type-group label {
    display: flex; align-items: center; gap: 6px; padding: 10px 20px;
    border: 2px solid #ddd; border-radius: 8px; cursor: pointer; font-weight: 600;
    transition: all 0.2s; font-size: 0.95em;
}
.invest-type-group input[type="radio"] { display: none; }
.invest-type-group label.active {
    border-color: #3cb371; background: #e8f5e9; color: #1b523c;
}

/* ─── 결과 카드 ─── */
.result-summary {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
    margin-bottom: 30px;
}
.summary-card {
    background: #fff; border-radius: 12px; padding: 18px 14px; text-align: center;
    border: 1px solid #e0e0e0; transition: transform 0.2s;
}
.summary-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.summary-card.highlight {
    background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
    border-color: #3cb371;
}
.summary-card .card-label { font-size: 0.82em; color: #666; margin-bottom: 6px; }
.summary-card .card-value { font-size: 1.5em; font-weight: 800; word-break: break-all; }
.summary-card .card-value.positive { color: #2e7d32; }
.summary-card .card-value.negative { color: #c62828; }
.summary-card .card-sub { font-size: 0.78em; color: #888; margin-top: 4px; }

/* ─── 상세 분석표 ─── */
.detail-section {
    background: #fff; border: 1px solid #e0e0e0; border-radius: 12px;
    margin-bottom: 16px; overflow: hidden;
}
.detail-header {
    padding: 14px 16px; background: #f8f9fa; cursor: pointer;
    display: flex; justify-content: space-between; align-items: center;
    font-weight: 700; color: #1b523c; font-size: 0.95em;
    border-bottom: 1px solid #e0e0e0;
}
.detail-header .toggle-icon { transition: transform 0.3s; font-size: 0.9em; }
.detail-header.collapsed .toggle-icon { transform: rotate(-90deg); }
.detail-body { padding: 0; }
.detail-body.collapsed { display: none; }

.detail-table { width: 100%; border-collapse: collapse; }
.detail-table tr { border-bottom: 1px solid #f0f0f0; }
.detail-table tr:last-child { border-bottom: none; }
.detail-table tr.subtotal { background: #f0fdf4; font-weight: 700; }
.detail-table tr.subtotal td { border-top: 2px solid #3cb371; }
.detail-table td { padding: 10px 14px; font-size: 0.9em; }
.detail-table td:first-child { color: #555; }
.detail-table td:last-child { text-align: right; font-weight: 600; color: #333; white-space: nowrap; }
.detail-table td .formula { font-size: 0.75em; color: #999; display: block; margin-top: 2px; }

/* 툴팁 */
.tip {
    display: inline-block; width: 16px; height: 16px; line-height: 16px;
    text-align: center; border-radius: 50%; background: #ddd; color: #666;
    font-size: 0.7em; cursor: help; margin-left: 3px; position: relative;
}
.tip:hover::after {
    content: attr(data-tip); position: absolute; bottom: 120%; left: 50%;
    transform: translateX(-50%); background: #333; color: #fff;
    padding: 6px 10px; border-radius: 6px; font-size: 12px;
    white-space: nowrap; z-index: 100; font-weight: 400;
    max-width: 250px; white-space: normal;
}

/* 버튼 */
.btn-analyze {
    display: block; width: 100%; padding: 14px; background: #3cb371;
    color: #fff; border: none; border-radius: 10px; font-size: 1.1em;
    font-weight: 700; cursor: pointer; margin-top: 10px;
}
.btn-analyze:hover { background: #2d8f5a; }
.btn-new { background: #f0f0f0; color: #333; border: 1px solid #ccc; }
.btn-new:hover { background: #e0e0e0; }

/* 체크박스 */
.checkbox-label {
    display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 0.9em;
}

/* ================================================
   태블릿 (768px 이하): 2열
   ================================================ */
@media (max-width: 768px) {
    .profit-form .field-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .result-summary {
        grid-template-columns: repeat(2, 1fr);
    }
    .summary-card .card-value { font-size: 1.3em; }
    .detail-table td { padding: 8px 12px; font-size: 0.85em; }
}

/* ================================================
   모바일 (480px 이하): 1열
   ================================================ */
@media (max-width: 480px) {
    .profit-container { padding: 8px 10px 30px; }

    .profit-form .section-card { padding: 14px 12px; margin-bottom: 14px; }
    .profit-form .section-title { font-size: 0.95em; margin-bottom: 12px; }

    .profit-form .field-grid {
        grid-template-columns: 1fr 1fr; /* 모바일도 2열 유지 (좁은 필드) */
        gap: 8px 10px;
    }
    .profit-form .field-group { padding-bottom: 16px; }
    .profit-form .field-group.full-width { grid-column: 1 / -1; }

    .profit-form .field-label { font-size: 0.8em; }
    .profit-form .field-row input { padding: 8px 6px; font-size: 0.88em; }
    .profit-form .field-unit { font-size: 0.78em; min-width: 16px; }

    .invest-type-group label { padding: 8px 14px; font-size: 0.88em; }

    /* 결과 카드 */
    .result-summary {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    .summary-card { padding: 14px 10px; }
    .summary-card .card-value { font-size: 1.15em; }
    .summary-card .card-label { font-size: 0.78em; }

    /* 상세 테이블 */
    .detail-header { padding: 12px 14px; font-size: 0.9em; }
    .detail-table td { padding: 8px 10px; font-size: 0.82em; }
    .detail-table td .formula { font-size: 0.7em; }

    /* 툴팁 모바일: 화면 밖으로 안 나가게 */
    .tip:hover::after {
        left: auto; right: 0; transform: none;
        max-width: 200px;
    }
}

/* ================================================
   극소 모바일 (360px 이하): 완전 1열
   ================================================ */
@media (max-width: 360px) {
    .profit-form .field-grid {
        grid-template-columns: 1fr;
    }
    .result-summary {
        grid-template-columns: 1fr;
    }
}
