/* ========================================
   금융계산기.kr - 대출 이자 계산기
   (예적금 계산기와 동일한 디자인 시스템)
   ======================================== */

/* ===== CSS VARIABLES ===== */
:root {
    --primary: #1a56e8;
    --primary-dark: #1340b8;
    --primary-light: #e8f0fe;
    --accent: #e85d1a;
    --accent-light: #fff3ee;

    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-2: #f8faff;
    --border: #e2e8f4;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;

    --shadow-sm: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-md: 0 4px 16px rgba(15, 23, 42, .10), 0 2px 6px rgba(15, 23, 42, .06);
    --shadow-lg: 0 10px 40px rgba(15, 23, 42, .14), 0 4px 12px rgba(15, 23, 42, .08);

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.7;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

ul {
    list-style: none;
}

.container {
    max-width: 1160px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===== HEADER ===== */
.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.logo-icon {
    font-size: 1.5rem;
}

.logo-accent {
    color: var(--primary);
}

.header-nav {
    display: flex;
    gap: 4px;
}

.nav-link {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition);
}

.nav-link:hover,
.nav-link.active {
    background: var(--primary-light);
    color: var(--primary);
}

/* ===== AD AREAS ===== */
.ad-banner-top,
.ad-banner-middle,
.ad-banner-bottom {
    background: var(--surface);
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.ad-banner-middle {
    border-top: 1px solid var(--border);
}

.ad-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: .75rem;
    letter-spacing: .1em;
}

.ad-slot--horizontal {
    height: 90px;
    width: 100%;
}

.ad-slot--sidebar {
    height: 260px;
    margin-bottom: 20px;
}

.ad-placeholder-text {
    opacity: .6;
}

/* ===== TOP DESCRIPTION ===== */
.top-description {
    background: linear-gradient(135deg, #e85d1a 0%, #c0390a 50%, #8b2000 100%);
    padding: 36px 0 32px;
    color: white;
}

.breadcrumb {
    font-size: .8rem;
    color: rgba(255, 255, 255, .65);
    margin-bottom: 12px;
}

.bc-sep {
    margin: 0 6px;
}

.bc-current {
    color: rgba(255, 255, 255, .9);
}

.main-title {
    font-size: clamp(1.6rem, 4vw, 2.4rem);
    font-weight: 800;
    margin-bottom: 12px;
    line-height: 1.3;
}

.main-subtitle {
    font-size: 1rem;
    color: rgba(255, 255, 255, .85);
    max-width: 640px;
    margin-bottom: 20px;
}

.main-subtitle strong {
    color: #fcd9bd;
}

.top-desc-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .25);
    color: rgba(255, 255, 255, .9);
    padding: 4px 12px;
    border-radius: 100px;
    font-size: .8rem;
    font-weight: 500;
}

/* ===== MAIN GRID ===== */
.main-content {
    padding: 32px 0;
}

.content-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    grid-template-areas: "calculator sidebar";
    gap: 28px;
    align-items: start;
}

.calculator-section {
    grid-area: calculator;
}

.sidebar {
    grid-area: sidebar;
}

/* ===== CALC CARD ===== */
.calc-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

.calc-card-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.calc-card-desc {
    color: var(--text-secondary);
    font-size: .9rem;
    margin-bottom: 28px;
}

.calc-card-desc strong {
    color: var(--primary);
}

/* ===== FORM ===== */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 28px;
}

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

.form-label {
    font-size: .85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .05em;
}

.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.form-input {
    width: 100%;
    padding: 13px 52px 13px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--surface-2);
    transition: all var(--transition);
    outline: none;
    appearance: textfield;
    -moz-appearance: textfield;
}

.form-input::-webkit-outer-spin-button,
.form-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.form-input:focus {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(26, 86, 232, .12);
}

.form-input.error {
    border-color: var(--danger);
}

.input-unit {
    position: absolute;
    right: 14px;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-muted);
    pointer-events: none;
}

.form-hint {
    font-size: .78rem;
    color: var(--text-muted);
    min-height: 16px;
}

.form-hint.formatted {
    color: var(--primary);
    font-weight: 500;
}

.period-hint {
    color: var(--text-muted);
    font-style: italic;
}

/* ===== REPAYMENT RADIO ===== */
.repayment-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.radio-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: .88rem;
    color: var(--text-secondary);
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    user-select: none;
}

.radio-label:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

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

.radio-label:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.radio-label strong {
    display: block;
    font-weight: 700;
    font-size: .9rem;
    margin-bottom: 2px;
}

.radio-label small {
    font-size: .75rem;
    color: var(--text-muted);
    font-weight: 400;
}

.radio-label:has(input:checked) small {
    color: var(--primary);
    opacity: .75;
}

.radio-custom {
    width: 18px;
    height: 18px;
    border: 2px solid #cbd5e1;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 2px;
    transition: all var(--transition);
}

.radio-label:has(input:checked) .radio-custom {
    border-color: var(--primary);
    background: var(--primary);
    box-shadow: inset 0 0 0 3px white;
}

/* ===== BUTTON ===== */
.calc-btn {
    width: 100%;
    padding: 16px 24px;
    background: linear-gradient(135deg, #e85d1a 0%, #c0390a 100%);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition);
    box-shadow: 0 4px 16px rgba(232, 93, 26, .4);
}

.calc-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(232, 93, 26, .5);
}

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

.btn-icon {
    font-size: 1.1rem;
}

/* ===== RESULT CARD ===== */
.result-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-lg);
    border: 2px solid #e85d1a;
    margin-bottom: 20px;
    animation: fadeSlideIn .4s ease;
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 20px;
}

.result-summary-box {
    background: linear-gradient(135deg, #e85d1a 0%, #c0390a 100%);
    border-radius: var(--radius-md);
    padding: 24px;
    color: white;
    text-align: center;
    margin-bottom: 20px;
}

.summary-label {
    font-size: .85rem;
    opacity: .8;
    margin-bottom: 4px;
}

.summary-amount {
    font-size: clamp(1.8rem, 5vw, 2.6rem);
    font-weight: 800;
    line-height: 1.2;
}

.summary-sub {
    font-size: .85rem;
    opacity: .75;
    margin-top: 8px;
}

/* Compare section */
.compare-section {
    margin-bottom: 24px;
}

.compare-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.compare-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.compare-item {
    background: var(--surface-2);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    text-align: center;
}

.compare-item.active-type {
    border-color: #e85d1a;
    background: #fff3ee;
}

.compare-type {
    font-size: .75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 6px;
}

.compare-item.active-type .compare-type {
    color: #e85d1a;
}

.compare-monthly {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.compare-total {
    font-size: .75rem;
    color: var(--text-muted);
}

/* Result Grid */
.result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.result-item {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
}

.result-item-label {
    font-size: .78rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 4px;
}

.result-item-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

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

.result-item-value.accent {
    color: #e85d1a;
}

.result-item-value.large {
    font-size: 1.3rem;
    color: #c0390a;
}

/* Chart */
.chart-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 28px;
    padding: 16px 0;
    flex-wrap: wrap;
}

.chart-wrap canvas {
    max-width: 200px;
    max-height: 200px;
}

.chart-legend {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: .85rem;
}

.legend-dot {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    flex-shrink: 0;
}

.legend-info {
    display: flex;
    flex-direction: column;
}

.legend-label {
    font-weight: 600;
    color: var(--text-secondary);
}

.legend-val {
    font-weight: 700;
    color: var(--text-primary);
}

.result-notice {
    font-size: .78rem;
    color: var(--text-muted);
    background: #f8faff;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--border);
    margin-top: 16px;
}

/* ===== AMORTIZATION TABLE ===== */
.schedule-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    animation: fadeSlideIn .5s ease;
}

.schedule-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.btn-toggle-all {
    padding: 8px 16px;
    background: var(--primary-light);
    color: var(--primary);
    border: 1.5px solid rgba(26, 86, 232, .2);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

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

.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.schedule-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

.schedule-table th {
    background: var(--text-primary);
    color: white;
    padding: 12px 14px;
    text-align: right;
    font-weight: 600;
    font-size: .8rem;
    white-space: nowrap;
}

.schedule-table th:first-child {
    text-align: center;
}

.schedule-table td {
    padding: 10px 14px;
    text-align: right;
    border-bottom: 1px solid var(--border);
    font-variant-numeric: tabular-nums;
}

.schedule-table td:first-child {
    text-align: center;
    font-weight: 600;
    color: var(--text-secondary);
}

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

.schedule-table tr:nth-child(even) td {
    background: var(--surface-2);
}

.schedule-table tr:hover td {
    background: var(--primary-light);
}

.schedule-table .total-row td {
    background: #fff3ee;
    font-weight: 700;
    color: #c0390a;
    border-top: 2px solid #e85d1a;
}

.schedule-table .grace-row td {
    background: #fffbeb;
    color: var(--warning);
}

.table-hint {
    text-align: center;
    padding: 14px;
    font-size: .82rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

/* ===== SIDEBAR ===== */
.sidebar {
    display: flex;
    flex-direction: column;
}

.sidebar-widget {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    margin-bottom: 18px;
}

.widget-title {
    font-size: .95rem;
    font-weight: 700;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-light);
}

.sidebar-links {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: .875rem;
    transition: all var(--transition);
    border: 1px solid transparent;
}

.sidebar-link:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: rgba(26, 86, 232, .15);
    transform: translateX(4px);
}

.sidebar-link.active-link {
    background: var(--primary-light);
    color: var(--primary);
    border-color: rgba(26, 86, 232, .2);
    font-weight: 600;
    cursor: default;
}

.link-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.link-info {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.link-info strong {
    font-weight: 600;
}

.link-info small {
    font-size: .73rem;
    color: var(--text-muted);
}

.tax-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}

.tax-table th,
.tax-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.tax-table th {
    background: var(--surface-2);
    font-weight: 700;
    font-size: .78rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.tax-rate {
    font-weight: 700;
    color: var(--danger);
}

.tax-rate.preferred {
    color: var(--warning);
}

.tax-rate.exempt {
    color: var(--success);
}

.rate-info-box {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.rate-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.rate-label {
    font-size: .83rem;
    color: var(--text-secondary);
}

.rate-value {
    font-weight: 700;
    font-size: .9rem;
    color: var(--primary);
    background: var(--primary-light);
    padding: 2px 10px;
    border-radius: 100px;
}

.rate-value.small {
    font-size: .78rem;
}

.widget-note {
    font-size: .73rem;
    color: var(--text-muted);
    margin-top: 10px;
    line-height: 1.5;
}

/* ===== BOTTOM DESC ===== */
.bottom-description {
    background: var(--surface);
    padding: 52px 0;
    border-top: 1px solid var(--border);
}

.info-section {
    margin-bottom: 44px;
}

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

.info-section>h2 {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 3px solid #e85d1a;
    display: inline-block;
}

.info-section>p {
    color: var(--text-secondary);
    margin-bottom: 14px;
    max-width: 780px;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.three-col {
    grid-template-columns: repeat(3, 1fr);
}

.info-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
}

.info-card.highlight-card {
    border-color: #e85d1a;
    background: #fff3ee;
}

.info-card h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.info-card p {
    font-size: .9rem;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 12px;
}

.feature-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.feature-list li {
    font-size: .85rem;
    color: var(--text-secondary);
}

.formula-box {
    background: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-top: 12px;
}

.formula-box p {
    color: rgba(255, 255, 255, .7);
    font-size: .8rem;
    margin-bottom: 4px;
}

.formula-box code {
    display: block;
    color: #fcd9bd;
    font-size: .82rem;
    font-family: 'Consolas', monospace;
    line-height: 1.6;
}

.mt-8 {
    margin-top: 10px !important;
}

/* FAQ */
.faq-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.faq-item {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.faq-item summary {
    padding: 16px 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: .95rem;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background var(--transition);
}

.faq-item summary::-webkit-details-marker {
    display: none;
}

.faq-item summary::after {
    content: '+';
    font-size: 1.3rem;
    color: #e85d1a;
    flex-shrink: 0;
    margin-left: 12px;
}

.faq-item[open] summary::after {
    content: '−';
}

.faq-item summary:hover {
    background: #fff3ee;
}

.faq-item p {
    padding: 12px 20px 16px;
    font-size: .9rem;
    color: var(--text-secondary);
    line-height: 1.7;
    border-top: 1px solid var(--border);
}

/* ===== FOOTER ===== */
.ad-banner-bottom {
    border-bottom: none;
    border-top: 1px solid var(--border);
}

.site-footer {
    background: var(--text-primary);
    color: rgba(255, 255, 255, .6);
    padding: 36px 0;
}

.footer-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
}

.footer-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
    font-weight: 800;
    color: white;
}

.footer-logo .logo-accent {
    color: #7dd3fc;
}

.footer-links {
    display: flex;
    gap: 20px;
}

.footer-links a {
    color: rgba(255, 255, 255, .55);
    font-size: .85rem;
    transition: color var(--transition);
}

.footer-links a:hover {
    color: white;
}

.footer-disclaimer {
    font-size: .78rem;
    max-width: 620px;
    line-height: 1.6;
}

.footer-copy {
    font-size: .78rem;
    color: rgba(255, 255, 255, .3);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    .content-grid {
        grid-template-columns: 1fr;
        grid-template-areas: "calculator" "sidebar";
    }

    .sidebar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }

    .ad-slot--sidebar {
        display: none;
    }

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

    .three-col {
        grid-template-columns: 1fr;
    }

    .repayment-group {
        grid-template-columns: 1fr !important;
    }

    .compare-grid {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 640px) {
    .header-nav {
        display: none;
    }

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

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

    .calc-card,
    .result-card,
    .schedule-card {
        padding: 20px;
    }

    .sidebar {
        display: flex;
        flex-direction: column;
    }

    .repayment-group {
        grid-template-columns: 1fr !important;
    }

    .compare-grid {
        grid-template-columns: 1fr !important;
    }
}