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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    line-height: 1.6;
}

/* PWA 설치 배너 */
.install-banner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    padding: 20px;
    max-width: 450px;
    width: calc(100% - 40px);
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s ease;
}

.install-banner.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.install-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

.install-icon {
    font-size: 2.5rem;
    flex-shrink: 0;
}

.install-text {
    flex: 1;
}

.install-text strong {
    display: block;
    color: #2d3748;
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.install-text p {
    color: #718096;
    font-size: 0.9rem;
    margin: 0;
}

.btn-install {
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-install:hover {
    background: #5568d3;
    transform: translateY(-2px);
}

.btn-dismiss {
    padding: 5px 12px;
    background: transparent;
    color: #a0aec0;
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
}

.btn-dismiss:hover {
    background: #edf2f7;
    color: #718096;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
}

header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
    padding: 20px;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

.card {
    background: white;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.card h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.5rem;
    border-bottom: 3px solid #667eea;
    padding-bottom: 10px;
}

.input-group {
    margin-bottom: 15px;
}

.input-group label {
    display: block;
    margin-bottom: 5px;
    color: #555;
    font-weight: 600;
}

.input-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.input-group input:focus {
    outline: none;
    border-color: #667eea;
}

.portfolio-setup {
    display: grid;
    grid-template-columns: 2fr 1fr auto;
    gap: 15px;
    align-items: end;
    margin-bottom: 20px;
}

.btn {
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #48bb78;
    color: white;
    width: 100%;
    margin-top: 15px;
}

.btn-secondary:hover {
    background: #38a169;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(72, 187, 120, 0.4);
}

.btn-danger {
    background: #f56565;
    color: white;
}

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

.btn-info {
    background: #4299e1;
    color: white;
}

.btn-info:hover {
    background: #3182ce;
}

.button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.assets-list {
    margin: 20px 0;
}

.asset-item {
    display: grid;
    grid-template-columns: 2fr 1fr auto;
    gap: 15px;
    align-items: center;
    padding: 15px;
    background: #f7fafc;
    border-radius: 8px;
    margin-bottom: 10px;
    border-left: 4px solid #667eea;
}

.asset-item:hover {
    background: #edf2f7;
}

.asset-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.asset-name {
    font-weight: 600;
    color: #2d3748;
    font-size: 1.1rem;
}

.asset-code-display {
    display: flex;
    align-items: center;
    gap: 8px;
}

.code-label {
    font-size: 0.85rem;
    color: #718096;
    font-weight: 500;
}

.code-input {
    padding: 6px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    font-size: 0.9rem;
    font-family: 'Courier New', monospace;
    color: #667eea;
    background: white;
    transition: all 0.2s;
    width: 180px;
}

.code-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.code-input:hover {
    border-color: #cbd5e0;
}

.asset-ratio {
    color: #667eea;
    font-weight: 600;
    text-align: center;
}

.btn-delete {
    padding: 8px 15px;
    background: #fc8181;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.9rem;
}

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

.total-ratio {
    padding: 15px;
    background: #667eea;
    color: white;
    border-radius: 8px;
    text-align: center;
    font-size: 1.2rem;
    font-weight: 700;
    margin-top: 15px;
}

/* 금액 입력 섹션 */
.amount-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.input-hint {
    display: block;
    font-size: 0.85rem;
    color: #718096;
    margin-top: 5px;
}

.total-amount-display {
    grid-column: 1 / -1;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
    text-align: center;
    font-size: 1.3rem;
    font-weight: 700;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.total-amount-display .label {
    font-weight: 600;
}

.total-amount-display .amount {
    font-size: 1.5rem;
    font-weight: 800;
}

.rebalancing-result {
    margin-top: 20px;
}

/* 모바일 카드 레이아웃 */
.result-cards {
    display: none; /* 기본적으로 숨김 (데스크톱) */
    flex-direction: column;
    gap: 15px;
}

.result-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-left: 4px solid #667eea;
}

.card-header {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
}

.card-header h3 {
    font-size: 1.1rem;
    color: #2d3748;
    margin: 0 0 5px 0;
}

.card-code {
    font-size: 0.85rem;
    color: #667eea;
    font-family: 'Courier New', monospace;
    font-weight: 600;
}

.card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f7fafc;
}

.card-row:last-child {
    border-bottom: none;
}

.card-label {
    font-size: 0.9rem;
    color: #718096;
    font-weight: 500;
}

.card-value {
    font-size: 1rem;
    color: #2d3748;
    font-weight: 600;
}

.input-row {
    flex-wrap: wrap;
}

.card-input-group {
    display: flex;
    gap: 8px;
    flex: 1;
    max-width: 200px;
}

.card-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.95rem;
    min-width: 0;
}

.card-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn-fetch-price-mini {
    padding: 8px 12px;
    background: #4299e1;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    white-space: nowrap;
    transition: all 0.2s;
}

.btn-fetch-price-mini:hover {
    background: #3182ce;
}

.btn-fetch-price-mini:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
}

.highlight-row {
    background: #f7fafc;
    margin: 10px -20px -20px -20px;
    padding: 15px 20px;
    border-radius: 0 0 12px 12px;
}

.card-value-highlight {
    font-size: 1.1rem;
    font-weight: 700;
    color: #2d3748;
}

.card-value-highlight .positive {
    color: #48bb78;
}

.card-value-highlight .negative {
    color: #f56565;
}

/* 데스크톱 테이블 */
.result-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.result-table th,
.result-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.result-table th {
    background: #667eea;
    color: white;
    font-weight: 600;
}

.result-table tr:hover {
    background: #f7fafc;
}

.result-table td input {
    width: 100%;
    padding: 8px;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
}

.result-table td.highlight {
    background: #fef5e7;
    font-weight: 700;
    color: #d69e2e;
}

.result-table td.positive {
    color: #48bb78;
    font-weight: 600;
}

.result-table td.negative {
    color: #f56565;
    font-weight: 600;
}

.alert {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.alert-warning {
    background: #fef5e7;
    color: #d69e2e;
    border-left: 4px solid #d69e2e;
}

.alert-error {
    background: #fff5f5;
    color: #c53030;
    border-left: 4px solid #c53030;
}

.alert-success {
    background: #f0fff4;
    color: #2f855a;
    border-left: 4px solid #2f855a;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: #a0aec0;
}

.empty-state svg {
    width: 100px;
    height: 100px;
    margin-bottom: 15px;
}

.price-input-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.price-input-group input {
    flex: 1;
}

.btn-fetch-price {
    padding: 8px 15px;
    background: #4299e1;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    white-space: nowrap;
}

.btn-fetch-price:hover {
    background: #3182ce;
}

.btn-fetch-price:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
}

/* 종목 검색 자동완성 */
.search-container {
    position: relative;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #667eea;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.search-results.active {
    display: block;
}

.search-result-item {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
}

.search-result-item:hover {
    background: #f7fafc;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-name {
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 3px;
}

.search-result-code {
    font-size: 0.9rem;
    color: #667eea;
    font-family: 'Courier New', monospace;
}

.search-result-category {
    display: inline-block;
    font-size: 0.8rem;
    padding: 2px 8px;
    background: #e6f2ff;
    color: #2b6cb0;
    border-radius: 4px;
    margin-left: 8px;
}

.no-results {
    padding: 15px;
    text-align: center;
    color: #a0aec0;
}

/* 반응형 디자인 */
@media (max-width: 768px) {
    .portfolio-setup {
        grid-template-columns: 1fr;
    }

    .asset-item {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .asset-ratio {
        text-align: left;
    }

    .code-input {
        width: 100%;
        max-width: 300px;
    }

    .asset-code-display {
        flex-wrap: wrap;
    }

    header h1 {
        font-size: 2rem;
    }

    .button-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    /* 모바일에서 테이블 숨기고 카드 표시 */
    .result-table {
        display: none;
    }

    .result-cards {
        display: flex;
    }

    .card-input-group {
        max-width: 100%;
        width: 100%;
    }

    .card-row.input-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .card-row.input-row .card-label {
        width: 100%;
    }

    .card-row.input-row .card-input,
    .card-row.input-row .card-input-group {
        width: 100%;
        max-width: 100%;
    }

    /* 금액 입력 반응형 */
    .amount-inputs {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .total-amount-display {
        flex-direction: column;
        gap: 5px;
    }

    .total-amount-display .amount {
        font-size: 1.3rem;
    }

    /* PWA 설치 배너 반응형 */
    .install-banner {
        bottom: 10px;
        width: calc(100% - 20px);
    }

    .install-content {
        flex-wrap: wrap;
    }

    .install-icon {
        font-size: 2rem;
    }

    .btn-install {
        width: 100%;
        margin-top: 10px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    .card {
        padding: 20px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .result-table {
        font-size: 0.8rem;
    }
}