
:root {
    --crypto-bg-dark: #0C0E15; 
    --crypto-bg-light: #131722; 
    --crypto-surface: #1E222D; 
    --crypto-border: #2A2E39; 
    --crypto-text: #F0F4F8;
    --crypto-text-muted: #B2B5BE;
    --crypto-up: #EF5350; 
    --crypto-down: #2962FF; 
    --crypto-primary: #2962FF; 
}


#crypto-exchange-modal .modal-content {
    background: var(--crypto-bg-dark);
    padding: 0; 
    border-radius: 4px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden; 
    color: var(--crypto-text);
}

#crypto-exchange-modal .close-button {
    position: absolute;
    top: 12px;
    right: 15px;
    z-index: 10;
    font-size: 28px;
    color: var(--crypto-text-muted);
}

#crypto-exchange-tabs {
    display: flex;
    align-items: center;
    background: var(--crypto-bg-light);
    border-bottom: 1px solid var(--crypto-border);
    flex-shrink: 0;
}

.exchange-tab-btn {
    padding: 15px 30px;
    font-size: 1.1rem;
    font-weight: bold;
    background: none;
    border: none;
    color: var(--crypto-text-muted);
    cursor: pointer;
    transition: color 0.2s, border-bottom-color 0.2s;
    border-bottom: 3px solid transparent;
}

.exchange-tab-btn:hover {
    color: var(--crypto-text);
}

.exchange-tab-btn.active {
    color: var(--crypto-primary);
    border-bottom-color: var(--crypto-primary);
}

.exchange-tab-content {
    flex-grow: 1;
    min-height: 0;
}

#crypto-exchange-container {
    gap: 8px;
    padding: 8px 8px 0 8px; 
    font-size: 0.8rem;
}

.crypto-panel {
    background: var(--crypto-bg-light);
    border-radius: 2px;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--crypto-border);
    overflow: hidden;
}

.crypto-price, .crypto-change, .crypto-volume,
#crypto-header-price, #crypto-header-change,
.wallet-summary-value, .crypto-portfolio-table td,
.crypto-order-input, .transfer-balance-item span:last-child,
#mobile-selected-coin-price {
    font-variant-numeric: tabular-nums;
}

#crypto-list-panel {
    flex: 0 0 380px;
    order: 2;
}

#crypto-trading-panel {
    flex: 1;
    order: 1; 
    display: flex;
    flex-direction: row;
}

#crypto-main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

#crypto-order-form-container {
    width: 350px;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--crypto-border);
}

#crypto-wallet-panel {
    height: 280px;
    margin: 8px;
    width: calc(100% - 16px);
    flex-direction: row;
    flex-shrink: 0;
}

#crypto-mobile-nav,
#crypto-mobile-header-info {
    display: none;
}



#crypto-search {
    width: calc(100% - 16px);
    margin: 8px;
    padding: 8px 10px;
    background: var(--crypto-bg-dark);
    border: 1px solid var(--crypto-border);
    color: var(--crypto-text);
    border-radius: 4px;
}

.crypto-table-header {
    display: grid;
    grid-template-columns: 2.2fr 2fr 1.6fr 3fr;
    padding: 10px 15px; 
    font-weight: bold;
    color: var(--crypto-text-muted);
    border-bottom: 2px solid var(--crypto-border); 
    font-size: 0.8rem;
    background-color: var(--crypto-surface);
}

.crypto-table-header span:not(:first-child) {
    text-align: right;
}

#crypto-list-body {
    flex-grow: 1;
    overflow-y: auto;
}

.crypto-list-item {
    display: grid;
    grid-template-columns: 2.2fr 2fr 1.6fr 3fr;
    padding: 6px 15px;
    cursor: pointer;
    transition: background-color 0.1s;
    border-bottom: 1px solid var(--crypto-border); 
    align-items: center; 
}

.crypto-list-item:hover {
    background-color: var(--crypto-surface);
}

.crypto-list-item.selected {
    background-color: var(--crypto-surface);
    box-shadow: inset 3px 0 0 var(--crypto-primary); 
}

.crypto-name {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}
.crypto-korean-name { font-weight: bold; font-size: 0.85rem; }

.crypto-symbol-line {
    display: flex;
    align-items: center; 
    gap: 6px;
}
.crypto-symbol { font-size: 0.7rem; color: var(--crypto-text-muted); }

.crypto-price, .crypto-change, .crypto-volume {
    text-align: right;
    font-size: 0.85rem;
}

.crypto-price {
    font-weight: bold;
}

.crypto-volume {
    color: var(--crypto-text);
    font-size: 0.75rem;
}

.coin-type-tag {
    padding: 2px 5px;
    font-size: 0.65rem;
    font-weight: bold;
    border-radius: 3px;
    line-height: 1;
    min-width: 30px; 
    text-align: center; 
    flex-shrink: 0;
}
.coin-type-tag.type-major { background-color: #2962FF; color: #FFFFFF; }
.coin-type-tag.type-alt { background-color: #27AE60; color: #FFFFFF; }
.coin-type-tag.type-meme { background-color: #f0b90b; color: #131722; }


#crypto-header {
    padding: 12px 15px;
    border-bottom: 1px solid var(--crypto-border);
    display: flex;
    align-items: baseline;
    gap: 15px;
}

#crypto-selected-coin {
    font-size: 1.3rem;
    margin: 0;
    font-weight: bold;
}

#crypto-header-price {
    font-size: 1.3rem;
    font-weight: bold;
}

#crypto-header-change {
    font-size: 0.85rem;
}

#crypto-chart-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 300px;
}

#crypto-timeframe-selector {
    display: flex;
    background: var(--crypto-bg-light);
    border-bottom: 1px solid var(--crypto-border);
}

.timeframe-btn {
    padding: 8px 12px;
    background: none;
    border: none;
    color: var(--crypto-text-muted);
    cursor: pointer;
    transition: color 0.2s;
    font-size: 0.8rem;
}
.timeframe-btn:hover { color: var(--crypto-text); }
.timeframe-btn.active { color: var(--crypto-primary); border-bottom: 2px solid var(--crypto-primary); }

#crypto-chart-container {
    flex-grow: 1;
    position: relative;
}

.crypto-order-tabs {
    display: flex;
}

.crypto-order-tab-btn {
    flex: 1;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    font-weight: bold;
    background: var(--crypto-bg-dark);
    border: none;
    color: var(--crypto-text-muted);
    border-bottom: 3px solid transparent;
    font-size: 0.9rem;
}

.crypto-order-tab-btn.active {
    color: var(--crypto-text);
    background: var(--crypto-bg-light);
}

#tab-buy.active { color: var(--crypto-up); border-bottom-color: var(--crypto-up); }
#tab-sell.active { color: var(--crypto-down); border-bottom-color: var(--crypto-down); }

.crypto-order-panel {
    display: none;
    padding: 15px;
    flex-direction: column;
    gap: 15px;
    flex-grow: 1;
}
.crypto-order-panel.active { display: flex; }

.crypto-order-input-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.crypto-order-input-group label { color: var(--crypto-text-muted); font-size: 0.8rem; }
.crypto-order-input-wrapper { flex: 0 0 70%; }

.crypto-order-input {
    width: 100%;
    padding: 10px;
    background: var(--crypto-surface);
    border: 1px solid var(--crypto-border);
    color: var(--crypto-text);
    text-align: right;
    border-radius: 4px;
    font-size: 0.9rem;
}
.crypto-order-input:focus { border-color: var(--crypto-primary); outline: none; }

.crypto-percent-buttons {
    display: flex;
    justify-content: space-between;
    gap: 5px;
}

.crypto-percent-btn {
    flex: 1;
    padding: 6px 0;
    background: var(--crypto-surface);
    border: 1px solid var(--crypto-border);
    color: var(--crypto-text-muted);
    cursor: pointer;
    font-size: 0.75rem;
    border-radius: 4px;
}
.crypto-percent-btn:hover { background-color: var(--crypto-border); }

.crypto-order-btn {
    padding: 12px;
    font-weight: bold;
    color: white;
    border: none;
    cursor: pointer;
    margin-top: 20px;
    border-radius: 4px;
    font-size: 1rem;
    transition: opacity 0.2s;
}
.crypto-order-btn:hover { opacity: 0.9; }
.crypto-order-btn:disabled { opacity: 0.5; cursor: not-allowed; }


#crypto-buy-btn { background-color: var(--crypto-up); }
#crypto-sell-btn { background-color: var(--crypto-down); }


/* --- Wallet Components --- */
#crypto-wallet-panel h3, #crypto-portfolio-container h3 {
    padding: 12px 15px;
    margin: 0;
    border-bottom: 1px solid var(--crypto-border);
    font-size: 0.95rem;
}

#crypto-wallet-summary-container {
    flex: 0 0 320px; 
    border-right: 1px solid var(--crypto-border);
}

#crypto-wallet-summary {
    padding: 15px;
}

.wallet-summary-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 0.85rem;
}
.wallet-summary-label { color: var(--crypto-text-muted); }
.wallet-summary-value { font-weight: bold; }

#crypto-portfolio-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#crypto-portfolio-list {
    flex-grow: 1;
    overflow-y: auto;
}

.crypto-portfolio-table {
    width: 100%;
    border-collapse: collapse;
}

.crypto-portfolio-table th, .crypto-portfolio-table td {
    padding: 8px 15px;
    text-align: right;
    border-bottom: 1px solid var(--crypto-border);
    font-size: 0.85rem;
}

.crypto-portfolio-table th {
    background-color: var(--crypto-bg-light);
    color: var(--crypto-text-muted);
    font-weight: 500;
    position: sticky;
    top: 0;
    z-index: 1;
}

.crypto-portfolio-table td:first-child, .crypto-portfolio-table th:first-child {
    text-align: left;
    font-variant-numeric: normal;
}

.portfolio-item-row {
    cursor: pointer;
    transition: background-color 0.1s;
}
.portfolio-item-row:hover { background-color: var(--crypto-surface); }


#crypto-transfer-section {
    flex: 0 0 350px; 
    padding: 15px;
    border-left: 1px solid var(--crypto-border);
    display: flex;
    flex-direction: column;
}

#crypto-transfer-section h4 {
    font-size: 0.95rem;
    margin-bottom: 8px;
}

#crypto-transfer-balances {
    margin-top: 15px;
    background: var(--crypto-surface);
    padding: 10px;
    border-radius: 4px;
}

.transfer-balance-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 8px;
}
.transfer-balance-item span:first-child { color: var(--crypto-text-muted); }
.transfer-balance-item span:last-child { font-weight: bold; }

#crypto-transfer-controls {
    display: flex;
    gap: 8px;
    margin-top: auto;
}

#crypto-transfer-amount {
    flex: 1;
    padding: 10px;
    background: var(--crypto-surface);
    border: 1px solid var(--crypto-border);
    color: var(--crypto-text);
    border-radius: 4px;
    font-size: 0.9rem;
}
#crypto-transfer-amount:focus { border-color: var(--crypto-primary); outline: none; }

.crypto-transfer-btn {
    padding: 10px 15px;
    background: var(--crypto-primary);
    color: white;
    border: none;
    cursor: pointer;
    font-weight: bold;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: opacity 0.2s;
}
.crypto-transfer-btn:hover { opacity: 0.9; }

.crypto-up { color: var(--crypto-up); }
.crypto-down { color: var(--crypto-down); }

#crypto-ranking-container {
    flex-direction: column;
    padding: 15px;
    margin: 8px;
    width: calc(100% - 16px);
}

#crypto-ranking-container h2 {
    margin-bottom: 20px;
    font-size: 1.2rem;
    color: var(--crypto-text);
}

.crypto-ranking-table-container {
    flex-grow: 1;
    overflow-y: auto;
    background: var(--crypto-bg-dark);
    border: 1px solid var(--crypto-border);
}

.crypto-ranking-table { width: 100%; border-collapse: collapse; }
.crypto-ranking-table th, .crypto-ranking-table td {
    padding: 12px 20px;
    text-align: left;
    border-bottom: 1px solid var(--crypto-border);
    font-size: 1rem;
}
.crypto-ranking-table th {
    background-color: var(--crypto-surface);
    color: var(--crypto-text-muted);
    font-weight: bold;
    position: sticky;
    top: 0;
}
.crypto-ranking-table td:nth-child(3) {
    text-align: center;
    font-weight: bold;
    color: var(--crypto-primary);
}
.crypto-ranking-table th:nth-child(3) {
    text-align: center;
}

#crypto-house-wallet {
    margin-left: 20px;
    margin-right: 20px;
    padding: 8px 18px;
    background: #000;
    border-radius: 6px;
    display: flex;
    align-items: baseline;
    gap: 12px;
    position: relative;
    overflow: hidden;
    border: 2px solid transparent;
    box-shadow: 
        inset 0 0 10px rgba(0, 0, 0, 0.8),
        0 0 15px rgba(0, 230, 210, 0.3);
}

#crypto-house-wallet::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 6px;
    border: 2px solid transparent;
    background: linear-gradient(120deg, var(--primal-color), var(--crypto-primary), var(--primal-color)) border-box;
    -webkit-mask: 
        linear-gradient(#fff 0 0) padding-box, 
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: destination-out;
    mask-composite: exclude;
    animation: border-flow-animation 4s linear infinite;
}

@keyframes border-flow-animation {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

#crypto-house-wallet span:first-child {
    font-family: 'Roboto Mono', monospace, sans-serif;
    font-size: 1em;
    color: var(--crypto-text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#house-wallet-balance {
    font-family: 'Roboto Mono', monospace, sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: #ffffff;
    font-variant-numeric: tabular-nums;
    text-shadow: 
        0 0 5px #fff,
        0 0 10px var(--primal-color),
        0 0 20px var(--primal-color);
    transition: all 0.3s ease;
}

@keyframes wallet-flash-animation {
    50% { 
        transform: scale(1.05);
        box-shadow: 
            inset 0 0 10px rgba(0, 0, 0, 0.8),
            0 0 25px var(--primal-color);
    }
}

.wallet-flash {
    animation: wallet-flash-animation 0.6s ease-out;
}



@media (max-width: 820px) {

    #crypto-exchange-modal .modal-content {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100vh;
        border-radius: 0;
        padding: 0;
        padding-bottom: 60px; 
    }

    #crypto-exchange-modal .close-button {
        top: 10px;
        right: 10px;
        font-size: 24px;
    }

    #crypto-exchange-tabs,
    #crypto-wallet-panel h3,
    #crypto-ranking-container h2,
    #crypto-header {
        display: none !important;
    }

    #crypto-exchange-container,
    #crypto-ranking-container,
    #crypto-wallet-panel,
    #crypto-trading-panel,
    #crypto-list-panel {
        display: none !important;
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;
        border: none;
        background: var(--crypto-bg-dark);
        flex-grow: 1;
    }

    .modal-content.mobile-view-list #crypto-exchange-container,
    .modal-content.mobile-view-list #crypto-list-panel {
        display: flex !important;
    }

    .modal-content.mobile-view-chart #crypto-exchange-container,
    .modal-content.mobile-view-chart #crypto-trading-panel {
        display: flex !important;
    }
    .modal-content.mobile-view-chart #crypto-order-form-container {
        display: none !important;
    }


    .modal-content.mobile-view-trade #crypto-exchange-container,
    .modal-content.mobile-view-trade #crypto-trading-panel,
    .modal-content.mobile-view-trade #crypto-wallet-panel {
         display: flex !important;
    }
    .modal-content.mobile-view-trade #crypto-main-area,
    .modal-content.mobile-view-trade #crypto-wallet-summary-container,
    .modal-content.mobile-view-trade #crypto-portfolio-container {
        display: none !important;
    }
    .modal-content.mobile-view-trade #crypto-exchange-container {
        flex-direction: column;
        overflow-y: auto; 
    }
    .modal-content.mobile-view-trade #crypto-trading-panel,
    .modal-content.mobile-view-trade #crypto-wallet-panel {
        flex-direction: column;
        height: auto;
    }
    .modal-content.mobile-view-trade #crypto-trading-panel {
        flex: 1 0 auto; 
    }
    .modal-content.mobile-view-trade #crypto-wallet-panel {
        flex: 0 0 auto; 
    }

    .modal-content.mobile-view-trade #crypto-order-form-container {
        width: 100%;
        border-left: none;
        flex: 1;
    }
    .modal-content.mobile-view-trade #crypto-transfer-section {
        width: 100%;
        border-left: none;
        border-top: 8px solid var(--crypto-bg-dark); 
        flex: 0 0 auto;
    }


.modal-content.mobile-view-assets #crypto-wallet-panel {
        display: flex !important;
        height: 100%;
        padding: 10px;
        flex-direction: column;
    }
    .modal-content.mobile-view-assets #crypto-wallet-summary-container,
    .modal-content.mobile-view-assets #crypto-transfer-section {
        display: none !important;
    }
    .modal-content.mobile-view-assets #crypto-portfolio-container {
        flex-grow: 1;
        min-height: 0;
    }
    .modal-content.mobile-view-assets #crypto-portfolio-container h3 {
        display: block;
        text-align: center;
        padding: 15px;
        font-size: 1.2rem;
    }
	
	.crypto-portfolio-table {
        display: block;
    }
    .crypto-portfolio-table thead {
        display: none;
    }
    .crypto-portfolio-table tbody {
        display: block;
    }
    .portfolio-item-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "name value"
            "amount pnl";
        padding: 15px 10px;
        margin-bottom: 8px;
        border-radius: 4px;
        background-color: var(--crypto-surface);
        border-left: 4px solid var(--crypto-primary);
    }
    .crypto-portfolio-table td {
        display: flex;
        flex-direction: column;
        text-align: left;
        border: none;
        padding: 5px;
    }
    .crypto-portfolio-table td::before {
        content: attr(data-label);
        font-size: 0.75rem;
        color: var(--crypto-text-muted);
        margin-bottom: 4px;
    }

    .portfolio-item-row td:nth-child(1) { grid-area: name; }
    .portfolio-item-row td:nth-child(2) { grid-area: amount; }
    .portfolio-item-row td:nth-child(3) { grid-area: value; text-align: right; }
    .portfolio-item-row td:nth-child(4) { grid-area: pnl; text-align: right; }

    .portfolio-item-row td:nth-child(1),
    .portfolio-item-row td:nth-child(3) {
        font-size: 1.1rem;
        font-weight: bold;
    }


    #crypto-mobile-header-info {
        display: none; 
    }
    
    .modal-content.coin-selected.mobile-view-chart #crypto-mobile-header-info,
    .modal-content.coin-selected.mobile-view-trade #crypto-mobile-header-info {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        background: var(--crypto-bg-light);
        border-bottom: 1px solid var(--crypto-border);
        padding: 10px 40px; 
        text-align: center;
        flex-shrink: 0;
        min-height: 60px;
    }

    #mobile-selected-coin-name {
        font-size: 16px;
        margin: 0 0 5px 0;
    }

    #mobile-selected-coin-price {
        font-size: 20px;
        font-weight: bold;
    }

    #mobile-selected-coin-change {
        font-size: 14px;
    }


    #crypto-search {
        width: calc(100% - 20px);
        margin: 10px;
        padding: 12px;
        font-size: 16px;
    }
    
    .crypto-table-header {
        grid-template-columns: 2fr 2fr 1.5fr; 
        padding: 8px 10px;
        font-size: 12px;
    }
    .header-volume { display: none; }

    .crypto-list-item {
        grid-template-columns: 2fr 2fr 1.5fr; 
        padding: 10px 10px;
        font-size: 14px;
    }
    .crypto-volume { display: none; }
    .crypto-korean-name { font-size: 14px; }
    .crypto-symbol { font-size: 12px; }
    
    .crypto-list-item.selected {
        box-shadow: none;
    }

    #crypto-trading-panel {
        flex-direction: column;
    }

    #crypto-main-area {
        flex: 1; 
        min-height: 0;
    }
    
    #crypto-chart-wrapper {
        min-height: 0;
    }

    .crypto-order-panel {
        padding: 15px;
        gap: 12px;
    }

    .crypto-order-input-group label { font-size: 14px; }
    .crypto-order-input-group span { font-size: 14px; }

    .crypto-order-input {
        padding: 12px;
        font-size: 16px;
    }

    .crypto-percent-btn {
        padding: 8px 0;
        font-size: 14px;
    }

    .crypto-order-btn {
        padding: 15px;
        font-size: 18px;
        margin-top: 10px;
    }

    #crypto-transfer-section {
        padding: 20px 15px;
    }
    #crypto-transfer-controls {
        flex-direction: row;
        gap: 10px;
    }
    #crypto-transfer-amount {
        padding: 12px;
        font-size: 16px;
    }
    .crypto-transfer-btn {
        flex: 1;
        padding: 12px;
        font-size: 16px;
    }

    #crypto-ranking-container {
        padding: 10px;
    }

    #crypto-mobile-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--crypto-bg-light);
        border-top: 1px solid var(--crypto-border);
        height: 60px;
        z-index: 15;
    }

    .mobile-nav-btn {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        color: var(--crypto-text-muted);
        padding: 5px 0;
        cursor: pointer;
    }

    .mobile-nav-btn.active {
        color: var(--crypto-primary);
    }
    
    .mobile-nav-btn:disabled {
        opacity: 0.4;
        cursor: not-allowed;
        color: var(--crypto-text-muted) !important;
    }

    .nav-icon {
        font-size: 22px;
        margin-bottom: 2px;
    }

    .nav-text {
        font-size: 12px;
    }
    
    .whale-monitoring-container {
        flex-direction: column;
        height: auto; 
        min-height: 500px; 
        gap: 10px;
    }
}