/* Base Variables */
:root {
    --bg-color: #0f172a;
    --text-color: #f8fafc;
    --text-muted: #94a3b8;
    --primary-color: #38bdf8;
    --accent-color: #818cf8;
    --text-primary: #f8fafc;
    /* Added missing variable */
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --input-bg: rgba(15, 23, 42, 0.6);
    --success-color: #4ade80;
    --danger-color: #f87171;
    --blob-1: #4f46e5;
    --blob-2: #0ea5e9;
    --blob-3: #c026d3;
}

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

body {
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    overflow-x: hidden;
    position: relative;
}

/* Background Blobs */
.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    filter: blur(80px);
    opacity: 0.4;
    border-radius: 50%;
    animation: float 20s infinite alternate;
}

.blob-1 {
    width: 400px;
    height: 400px;
    background: var(--blob-1);
    top: -100px;
    left: -100px;
}

.blob-2 {
    width: 500px;
    height: 500px;
    background: var(--blob-2);
    bottom: -150px;
    right: -150px;
    animation-delay: -5s;
}

.blob-3 {
    width: 300px;
    height: 300px;
    background: var(--blob-3);
    top: 40%;
    left: 40%;
    animation-delay: -10s;
}

@keyframes float {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(50px, 50px) scale(1.1);
    }
}

.container {
    width: 100%;
    max-width: 1000px;
    z-index: 1;
}

header {
    text-align: center;
    margin-bottom: 3rem;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 700;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.calculator-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 768px) {
    .calculator-grid {
        grid-template-columns: 1fr;
    }
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

h2 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    color: var(--text-color);
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.5rem;
}

h3 {
    font-size: 1.1rem;
    margin-bottom: 1.25rem;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--input-bg);
    border-radius: 10px;
    padding: 0 1rem;
    border: 1px solid var(--glass-border);
    transition: 0.3s;
}

.input-wrapper:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.input-wrapper input {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-color);
    font-size: 1.1rem;
    padding: 0.8rem 0;
    outline: none;
    font-weight: 500;
    font-family: inherit;
}

.unit {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-left: 0.5rem;
}

.price-display {
    font-size: 0.85rem;
    color: var(--primary-color);
    margin-top: 0.4rem;
    text-align: right;
    min-height: 1.2em;
}

.range-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.range-wrapper input[type="range"] {
    flex: 1;
    height: 6px;
    background: var(--input-bg);
    border-radius: 5px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.range-wrapper input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    transition: 0.2s;
}

.input-wrapper.small {
    width: 100px;
}

/* Result Section Styling */
.result-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    text-align: center;
}

.result-card.primary {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(129, 140, 248, 0.2));
    border: 1px solid rgba(56, 189, 248, 0.3);
}

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

.label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.value {
    display: block;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-color);
    word-break: keep-all;
    /* Prevent breaking in middle of words/units */
}

/* Ensure Result Row values don't wrap awkwardly */
.result-row strong {
    font-size: 1.2rem;
    color: var(--primary-color);
    white-space: nowrap;
}

.label-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    /* Decreased font size */
}

.label-row .label-text {
    color: var(--text-muted);
    font-weight: 400;
}

.label-row .value-text {
    font-weight: 600;
    color: var(--text-color);
    font-size: 1rem;
}

/* Legend Styling */
.legend-container {
    display: flex;
    gap: 1.25rem;
    margin-top: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

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

.highlight-red {
    color: var(--danger-color);
}

.highlight-green {
    color: var(--success-color);
}

.divider {
    height: 1px;
    background: var(--glass-border);
    margin: 1.5rem 0;
}

.result-card.highlight {
    background: rgba(74, 222, 128, 0.1);
    border: 1px solid rgba(74, 222, 128, 0.3);
}

.sub-text {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* Assets Grid */
.assets-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
    margin-bottom: 0.5rem;
}

.input-wrapper.mini {
    padding: 0 0.8rem;
}

.input-wrapper.mini input {
    font-size: 0.95rem;
    padding: 0.6rem 0;
}

.unit-mini {
    color: var(--text-muted);
    font-size: 0.8rem;
    white-space: nowrap;
    margin-left: 0.3rem;
}

.total-asset-display {
    text-align: right;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.highlight-asset {
    color: var(--success-color);
    font-weight: 700;
}

/* DSR Card */
.dsr-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    transition: all 0.3s ease;
}

.flex-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.dsr-card .label {
    margin-bottom: 0;
}

.dsr-badge {
    font-size: 0.8rem;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    background: var(--glass-border);
    color: var(--text-muted);
    font-weight: 500;
}

/* Dynamic DSR Colors */
.dsr-safe {
    border-color: rgba(74, 222, 128, 0.3);
    background: rgba(74, 222, 128, 0.05);
}

.dsr-safe .dsr-badge {
    background: rgba(74, 222, 128, 0.2);
    color: var(--success-color);
}

.dsr-caution {
    border-color: rgba(251, 191, 36, 0.3);
    background: rgba(251, 191, 36, 0.05);
}

.dsr-caution .dsr-badge {
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
}

.dsr-danger {
    border-color: rgba(248, 113, 113, 0.3);
    background: rgba(248, 113, 113, 0.05);
}

.dsr-danger .dsr-badge {
    background: rgba(248, 113, 113, 0.2);
    color: var(--danger-color);
}

/* Debt List Styles */
.btn-add {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    box-shadow: 0 4px 10px rgba(56, 189, 248, 0.3);
}

.btn-add:hover {
    transform: scale(1.1);
    background: #0ea5e9;
}

.debt-item {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.8rem;
    animation: slideIn 0.3s ease-out;
    position: relative;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

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

.debt-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
}

.debt-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-color);
}

.btn-remove {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 0.5rem;
    transition: 0.2s;
}

.btn-remove:hover {
    color: var(--danger-color);
}

.debt-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
}

.debt-input-group label {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 0.3rem;
    /* Explicit margin for labels inside grid */
}

/* Ensure inputs in dynamic cards look good */
.debt-input-group select,
.debt-input-group input {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-color);
    padding: 0.6rem;
    border-radius: 8px;
    outline: none;
    font-family: inherit;
    font-size: 0.9rem;
}

.debt-input-group select:focus,
.debt-input-group input:focus {
    border-color: var(--primary-color);
}

.full-width {
    grid-column: span 2;
}

.hint-text {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.flex-row.nowrap {
    align-items: center;
    gap: 10px;
}

/* Chart Container */
.chart-container {
    margin-top: 1.5rem;
    width: 100%;
}

.chart-wrapper {
    position: relative;
    height: 280px;
    /* Reduced height for better aspect ratio */
    width: 100%;
    margin-top: 1rem;
}

/* Date Picker & Grace Period Styles */
.date-select-row {
    display: flex;
    gap: 0.5rem;
}

.date-select-row select {
    flex: 1;
}

.checkbox-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0;
}

.checkbox-group label {
    margin-bottom: 0 !important;
    cursor: pointer;
    font-size: 0.85rem;
    white-space: nowrap;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    cursor: pointer;
}

.input-wrapper select {
    outline: none;
}

/* Fund Breakdown Visual Styles */
.fund-bar-container {
    display: flex;
    width: 100%;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.fund-bar {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    font-weight: 600;
    transition: all 0.3s ease;
    position: relative;
    min-width: 80px;
}

.fund-bar:hover {
    filter: brightness(1.1);
    transform: scaleY(1.05);
}

.fund-bar-label {
    font-size: 0.75rem;
    opacity: 0.9;
    margin-bottom: 2px;
}

.fund-bar-value {
    font-size: 0.85rem;
    font-weight: 700;
}

.fund-result {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(220, 38, 38, 0.1) 100%);
    border-radius: 12px;
    border: 2px solid rgba(239, 68, 68, 0.3);
}

.fund-result.positive {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(5, 150, 105, 0.1) 100%);
    border-color: rgba(16, 185, 129, 0.3);
}

.fund-result-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.fund-result-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #ef4444;
}

.fund-result.positive .fund-result-value {
    color: #10b981;
}

/* Inquiry Section Styles */
.inquiry-section {
    width: 100%;
    margin-bottom: 2rem;
}

.inquiry-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 640px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
}

.btn-submit {
    background: linear-gradient(to right, var(--primary-color), var(--accent-color));
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(56, 189, 248, 0.3);
}

.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(56, 189, 248, 0.4);
    filter: brightness(1.1);
}

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