/* Crypto Trading Platform - Terminal Pro Theme */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    /* Core Background Palette */
    --bg-void: #05080c;
    --bg-primary: #0a0e14;
    --bg-secondary: #0f1419;
    --bg-tertiary: #151c24;
    --bg-elevated: #1a222c;
    --bg-glass: rgba(15, 20, 25, 0.85);

    /* Text Hierarchy */
    --text-primary: #f0f4f8;
    --text-secondary: #8892a2;
    --text-tertiary: #5c6370;
    --text-muted: #3d4450;

    /* Trading Colors - Vibrant */
    --green-primary: #00f5a0;
    --green-secondary: #22c55e;
    --green-dim: #16a34a;
    --green-glow: rgba(0, 245, 160, 0.4);
    --green-bg: rgba(0, 245, 160, 0.08);

    --red-primary: #ff6b6b;
    --red-secondary: #ef4444;
    --red-dim: #dc2626;
    --red-glow: rgba(255, 107, 107, 0.4);
    --red-bg: rgba(255, 107, 107, 0.08);

    /* Accent Colors */
    --accent-blue: #3b82f6;
    --accent-cyan: #06b6d4;
    --accent-purple: #8b5cf6;

    /* Exchange Brand Colors */
    --upbit-primary: #0062df;
    --upbit-secondary: #0052ba;
    --upbit-glow: rgba(0, 98, 223, 0.3);

    --binance-primary: #f0b90b;
    --binance-secondary: #d4a307;
    --binance-glow: rgba(240, 185, 11, 0.3);

    --bithumb-primary: #f37321;
    --bithumb-secondary: #d45f1a;
    --bithumb-glow: rgba(243, 115, 33, 0.3);

    /* Borders & Lines */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-default: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.15);

    /* Shadows & Glows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow-green: 0 0 20px var(--green-glow);
    --shadow-glow-red: 0 0 20px var(--red-glow);

    /* Typography */
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
    --font-ui: 'Outfit', -apple-system, sans-serif;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;

    /* Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Transitions */
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);

    /* Layout */
    --content-max-width: 1600px;
}

/* Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

fieldset {
    border: none;
    padding: 0;
    margin: 0;
}

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-ui);
    background: var(--bg-void);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Subtle grid background pattern */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
    z-index: -1;
}

/* ============================================
   HEADER / NAVIGATION
   ============================================ */
.header {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: var(--content-max-width);
    margin: 0 auto;
    height: 56px;
    padding: 0 var(--space-lg);
}

.logo {
    font-family: var(--font-ui);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.logo::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--green-primary);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--green-glow);
    animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
    0%, 100% { opacity: 1; box-shadow: 0 0 8px var(--green-glow); }
    50% { opacity: 0.6; box-shadow: 0 0 4px var(--green-glow); }
}

.nav-links {
    display: flex;
    gap: var(--space-xs);
    list-style: none;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.9rem;
    transition: var(--transition-fast);
    position: relative;
}

.nav-links a:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

.nav-links a.active {
    color: var(--accent-blue);
}

.nav-links a.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 2px;
    background: var(--accent-blue);
    border-radius: 1px;
}

/* ============================================
   COMPARE PAGE
   ============================================ */
.compare-page {
    min-height: 100vh;
    background: linear-gradient(180deg, var(--bg-void) 0%, var(--bg-primary) 100%);
}

.compare-header {
    padding: var(--space-lg) var(--space-xl);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-glass);
    backdrop-filter: blur(8px);
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: var(--space-lg);
    color: var(--text-primary);
}

.compare-controls {
    display: flex;
    align-items: center;
    gap: var(--space-xl);
    flex-wrap: wrap;
}

.compare-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 400px;
    color: var(--text-tertiary);
    gap: var(--space-md);
}

.compare-placeholder::before {
    content: '📊';
    font-size: 3rem;
    opacity: 0.5;
}

.compare-content {
    padding: var(--space-xl);
    max-width: var(--content-max-width);
    margin: 0 auto;
}

.compare-section {
    margin-bottom: var(--space-xl);
}

.section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.section-title::before {
    content: '';
    width: 3px;
    height: 14px;
    background: var(--accent-blue);
    border-radius: 2px;
}

/* ============================================
   TICKER SEARCH
   ============================================ */
.ticker-search {
    position: relative;
    width: 280px;
}

.ticker-search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    padding-left: 2.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition-fast);
}

.ticker-search::before {
    content: '⌕';
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    font-size: 1rem;
    pointer-events: none;
}

.ticker-search-input::placeholder {
    color: var(--text-tertiary);
    font-family: var(--font-ui);
    font-weight: 400;
}

.ticker-search-input:focus {
    outline: none;
    border-color: var(--accent-blue);
    background: var(--bg-elevated);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.ticker-search-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    max-height: 320px;
    overflow-y: auto;
    z-index: 100;
    list-style: none;
    box-shadow: var(--shadow-lg);
    animation: dropdown-enter 0.2s ease-out;
}

@keyframes dropdown-enter {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.ticker-search-dropdown::-webkit-scrollbar {
    width: 6px;
}

.ticker-search-dropdown::-webkit-scrollbar-track {
    background: transparent;
}

.ticker-search-dropdown::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 3px;
}

.ticker-search-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition-fast);
    border-bottom: 1px solid var(--border-subtle);
}

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

.ticker-search-item:hover,
.ticker-search-item.focused {
    background: var(--bg-elevated);
}

.ticker-search-item.focused {
    outline: 2px solid var(--accent-primary);
    outline-offset: -2px;
}

.ticker-symbol {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.ticker-name {
    color: var(--text-tertiary);
    font-size: 0.8rem;
}

/* ============================================
   EXCHANGE SELECTOR
   ============================================ */
.exchange-selector {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
}

.exchange-selector-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.exchange-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.exchange-buttons {
    display: flex;
    gap: var(--space-xs);
}

.exchange-btn {
    padding: 0.5rem 1rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-family: var(--font-ui);
    font-weight: 500;
    font-size: 0.85rem;
    transition: var(--transition-fast);
}

.exchange-btn:hover {
    background: var(--bg-glass);
    border-color: var(--text-tertiary);
    color: var(--text-primary);
}

.exchange-btn.active[data-exchange="upbit"],
.exchange-btn.active:first-child {
    background: var(--upbit-primary);
    border-color: var(--upbit-primary);
    color: white;
    box-shadow: 0 0 16px var(--upbit-glow);
}

.exchange-btn.active[data-exchange="binance"],
.exchange-btn.active:nth-child(2) {
    background: var(--binance-primary);
    border-color: var(--binance-primary);
    color: var(--bg-void);
    box-shadow: 0 0 16px var(--binance-glow);
}

.exchange-btn.active[data-exchange="bithumb"],
.exchange-btn.active:nth-child(3) {
    background: var(--bithumb-primary);
    border-color: var(--bithumb-primary);
    color: white;
    box-shadow: 0 0 16px var(--bithumb-glow);
}

.exchange-selector-divider {
    display: flex;
    align-items: center;
    padding: 0 var(--space-sm);
}

.vs-badge {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--bg-void);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    letter-spacing: 0.1em;
}

/* ============================================
   CHART BOARD
   ============================================ */
.chart-board {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-subtle);
    overflow: hidden;
}

.chart-board-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-subtle);
}

.chart-board-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--border-subtle);
}

.chart-container {
    background: var(--bg-secondary);
    padding: var(--space-lg);
    position: relative;
}

.chart-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.chart-upbit::before {
    background: linear-gradient(90deg, var(--upbit-primary), transparent);
}

.chart-binance::before {
    background: linear-gradient(90deg, var(--binance-primary), transparent);
}

.chart-bithumb::before {
    background: linear-gradient(90deg, var(--bithumb-primary), transparent);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
}

.chart-title {
    font-weight: 600;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.chart-upbit .chart-title::before {
    content: '';
    width: 10px;
    height: 10px;
    background: var(--upbit-primary);
    border-radius: 2px;
}

.chart-binance .chart-title::before {
    content: '';
    width: 10px;
    height: 10px;
    background: var(--binance-primary);
    border-radius: 2px;
}

.chart-bithumb .chart-title::before {
    content: '';
    width: 10px;
    height: 10px;
    background: var(--bithumb-primary);
    border-radius: 2px;
}

.chart-market {
    font-family: var(--font-mono);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.2rem 0.6rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.chart-interval {
    font-family: var(--font-mono);
    color: var(--text-tertiary);
    font-size: 0.8rem;
    padding: 0.2rem 0.5rem;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
}

.chart-canvas {
    width: 100%;
    height: 280px;
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
}

.chart-price {
    margin-top: var(--space-md);
    font-family: var(--font-mono);
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.price-up {
    color: var(--green-primary);
    text-shadow: 0 0 20px var(--green-glow);
}

.price-down {
    color: var(--red-primary);
    text-shadow: 0 0 20px var(--red-glow);
}

/* ============================================
   INTERVAL SELECTOR
   ============================================ */
.interval-selector {
    display: flex;
    gap: 2px;
    background: var(--bg-void);
    padding: 3px;
    border-radius: var(--radius-md);
}

.interval-btn {
    padding: 0.4rem 0.8rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    cursor: pointer;
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 0.8rem;
    transition: var(--transition-fast);
}

.interval-btn:hover {
    color: var(--text-secondary);
    background: var(--bg-tertiary);
}

.interval-btn.active {
    background: var(--accent-blue);
    color: white;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.spread-info {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 600;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.spread-label {
    color: var(--text-tertiary);
    font-weight: 400;
}

.spread-positive {
    color: var(--green-primary);
    background: var(--green-bg);
}

.spread-negative {
    color: var(--red-primary);
    background: var(--red-bg);
}

/* ============================================
   ORDERBOOK
   ============================================ */
.orderbook-compare {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-subtle);
    overflow: hidden;
}

.orderbook-compare-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-subtle);
}

.compare-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.price-diff {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
}

.price-diff.diff-positive {
    color: var(--green-primary);
    background: var(--green-bg);
}

.price-diff.diff-negative {
    color: var(--red-primary);
    background: var(--red-bg);
}

.orderbook-compare-content {
    display: grid;
    grid-template-columns: 1fr 1px 1fr;
    min-height: 500px;
}

.orderbook-divider {
    background: var(--border-default);
}

.orderbook {
    padding: var(--space-md);
    position: relative;
}

.orderbook::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
}

.orderbook-upbit::before {
    background: linear-gradient(90deg, var(--upbit-primary), transparent);
}

.orderbook-binance::before {
    background: linear-gradient(90deg, var(--binance-primary), transparent);
}

.orderbook-bithumb::before {
    background: linear-gradient(90deg, var(--bithumb-primary), transparent);
}

.orderbook-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border-subtle);
}

.orderbook-title {
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.orderbook-upbit .orderbook-title { color: var(--upbit-primary); }
.orderbook-binance .orderbook-title { color: var(--binance-primary); }
.orderbook-bithumb .orderbook-title { color: var(--bithumb-primary); }

.orderbook-spread {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-tertiary);
    background: var(--bg-elevated);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
}

.orderbook-content {
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.orderbook-asks,
.orderbook-bids {
    display: flex;
    flex-direction: column;
}

.orderbook-mid {
    text-align: center;
    padding: var(--space-sm) var(--space-md);
    margin: var(--space-sm) 0;
    background: linear-gradient(90deg, var(--bg-elevated), var(--bg-tertiary), var(--bg-elevated));
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
}

.mid-price {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--accent-cyan);
    text-shadow: 0 0 12px rgba(6, 182, 212, 0.4);
}

.orderbook-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: var(--space-sm);
    padding: 0.35rem 0.5rem;
    position: relative;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.orderbook-row:hover {
    background: var(--bg-elevated);
}

.orderbook-row .price,
.orderbook-row .quantity {
    position: relative;
    z-index: 1;
}

.orderbook-row .price {
    font-weight: 600;
}

.orderbook-row .quantity {
    text-align: right;
    color: var(--text-secondary);
}

.depth-bar {
    position: absolute;
    top: 2px;
    bottom: 2px;
    border-radius: 2px;
    transition: width 0.3s ease;
}

.bid-bar {
    right: 0;
    background: linear-gradient(90deg, transparent, var(--green-bg));
    border-right: 2px solid var(--green-dim);
}

.ask-bar {
    left: 0;
    background: linear-gradient(270deg, transparent, var(--red-bg));
    border-left: 2px solid var(--red-dim);
}

.orderbook-row.bid .price { color: var(--green-primary); }
.orderbook-row.ask .price { color: var(--red-primary); }

.price-diff-indicator {
    font-size: 0.7rem;
    padding: 0.1rem 0.3rem;
    border-radius: 2px;
    font-weight: 500;
}

.price-diff-indicator.diff-positive {
    color: var(--green-secondary);
    background: var(--green-bg);
}

.price-diff-indicator.diff-negative {
    color: var(--red-secondary);
    background: var(--red-bg);
}

/* Price Comparison Highlighting */
.orderbook-row.price-better {
    background: var(--green-bg);
    border-left: 2px solid var(--green-primary);
}

.orderbook-row.price-worse {
    background: var(--red-bg);
    border-left: 2px solid var(--red-dim);
}

/* Better Exchange Indicator */
.orderbook-better {
    box-shadow: inset 0 0 0 1px var(--green-primary);
}

.orderbook-better::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--green-primary);
    box-shadow: 0 0 12px var(--green-glow);
}

.better-badge {
    background: var(--green-primary);
    color: var(--bg-void);
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    box-shadow: 0 0 12px var(--green-glow);
}

/* ============================================
   LIVE UPDATE INDICATOR
   ============================================ */
.update-indicator {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--green-primary);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.update-indicator::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--green-primary);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--green-glow);
    animation: live-pulse 1.5s ease-in-out infinite;
}

@keyframes live-pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
        box-shadow: 0 0 8px var(--green-glow);
    }
    50% {
        opacity: 0.5;
        transform: scale(0.85);
        box-shadow: 0 0 4px var(--green-glow);
    }
}

/* ============================================
   EXCHANGE BADGES
   ============================================ */
.exchange-badge {
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.exchange-badge.upbit {
    background: var(--upbit-primary);
    color: white;
    box-shadow: 0 0 10px var(--upbit-glow);
}

.exchange-badge.binance {
    background: var(--binance-primary);
    color: var(--bg-void);
    box-shadow: 0 0 10px var(--binance-glow);
}

.exchange-badge.bithumb {
    background: var(--bithumb-primary);
    color: white;
    box-shadow: 0 0 10px var(--bithumb-glow);
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 1200px) {
    .compare-content {
        padding: var(--space-lg);
    }
}

@media (max-width: 992px) {
    .chart-board-content {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .chart-container {
        border-bottom: 1px solid var(--border-subtle);
    }

    .chart-container:last-child {
        border-bottom: none;
    }

    .orderbook-compare-content {
        grid-template-columns: 1fr;
    }

    .orderbook-divider {
        height: 1px;
        width: 100%;
    }
}

@media (max-width: 768px) {
    html {
        font-size: 13px;
    }

    .compare-header {
        padding: var(--space-md);
    }

    .compare-controls {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-md);
    }

    .ticker-search {
        width: 100%;
    }

    .exchange-selector {
        flex-wrap: wrap;
        justify-content: center;
    }

    .chart-board-header {
        flex-direction: column;
        gap: var(--space-md);
        align-items: flex-start;
    }

    .interval-selector {
        width: 100%;
        justify-content: space-between;
    }

    .orderbook-row {
        font-size: 0.8rem;
    }

    .chart-price {
        font-size: 1.4rem;
    }
}

@media (max-width: 480px) {
    .nav {
        padding: 0 var(--space-md);
    }

    .logo {
        font-size: 1rem;
    }

    .nav-links a {
        padding: var(--space-sm);
        font-size: 0.85rem;
    }

    .page-title {
        font-size: 1.25rem;
    }

    .exchange-btn {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Screen reader only - visually hidden but accessible */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.text-green { color: var(--green-primary); }
.text-red { color: var(--red-primary); }
.text-muted { color: var(--text-tertiary); }

.bg-green { background: var(--green-bg); }
.bg-red { background: var(--red-bg); }

.glow-green { text-shadow: 0 0 16px var(--green-glow); }
.glow-red { text-shadow: 0 0 16px var(--red-glow); }

/* Animation for price updates */
@keyframes price-flash-up {
    0% { background: var(--green-bg); }
    100% { background: transparent; }
}

@keyframes price-flash-down {
    0% { background: var(--red-bg); }
    100% { background: transparent; }
}

.flash-up {
    animation: price-flash-up 0.5s ease-out;
}

.flash-down {
    animation: price-flash-down 0.5s ease-out;
}

/* ============================================
   CONTAINER & GENERAL LAYOUT
   ============================================ */
.container {
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: var(--space-xl);
}

.container h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: var(--space-md);
    background: linear-gradient(135deg, var(--text-primary), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.container > p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: var(--space-xl);
}

/* ============================================
   HOME PAGE - FEATURES
   ============================================ */
.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-lg);
    margin-top: var(--space-xl);
}

.feature {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    transition: var(--transition-base);
    position: relative;
    overflow: hidden;
}

.feature::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
    opacity: 0;
    transition: var(--transition-base);
}

.feature:hover {
    border-color: var(--border-default);
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.feature:hover::before {
    opacity: 1;
}

.feature h3 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: var(--space-sm);
    color: var(--text-primary);
}

.feature p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* ============================================
   MARKETS PAGE
   ============================================ */
.markets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--space-md);
}

.market-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    transition: var(--transition-base);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.market-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--green-primary);
    opacity: 0;
    transition: var(--transition-base);
}

.market-card:hover {
    border-color: var(--border-default);
    background: var(--bg-tertiary);
}

.market-card:hover::before {
    opacity: 1;
}

.market-card h3 {
    font-family: var(--font-mono);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-cyan);
    margin-bottom: var(--space-xs);
}

.market-card .name {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: var(--space-md);
}

.market-card .price {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--green-primary);
    text-shadow: 0 0 12px var(--green-glow);
}

/* ============================================
   ERROR STATES
   ============================================ */
.error {
    background: var(--red-bg);
    border: 1px solid var(--red-dim);
    border-radius: var(--radius-md);
    padding: var(--space-md) var(--space-lg);
    color: var(--red-primary);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.error-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: var(--red-primary);
    color: var(--bg-void);
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.error-text {
    flex: 1;
}

/* ============================================
   EMPTY STATES
   ============================================ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
    color: var(--text-tertiary);
    text-align: center;
    min-height: 200px;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
    opacity: 0.5;
}

.empty-title {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.empty-description {
    font-size: 0.9rem;
    color: var(--text-tertiary);
}

/* ============================================
   LOADING STATES
   ============================================ */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
    color: var(--text-secondary);
}

.loading::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-default);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    margin-right: var(--space-sm);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   GAP REBALANCING PAGE
   ============================================ */
.rebalancing-page {
    min-height: calc(100vh - 60px);
    background: var(--bg-primary);
    padding: var(--space-lg);
}

.rebalancing-container {
    max-width: var(--content-max-width);
    margin: 0 auto;
}

.rebalancing-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    gap: var(--space-md);
    color: var(--text-secondary);
}

.rebalancing-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
}


/* iOS-style Toggle Switch */
.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    flex-shrink: 0;
}

.toggle-switch__track {
    display: block;
    width: 100%;
    height: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: 12px;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.toggle-switch__knob {
    display: block;
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: var(--text-tertiary);
    border-radius: 50%;
    transition: transform 0.2s ease, background 0.2s ease;
}

/* Active (ON) state */
.toggle-switch.active .toggle-switch__track {
    background: var(--green-bg);
    border-color: var(--green-dim);
}

.toggle-switch.active .toggle-switch__knob {
    transform: translateX(20px);
    background: var(--green-primary);
    box-shadow: 0 0 6px var(--green-glow);
}

/* Disabled state */
.toggle-switch:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Focus state for accessibility */
.toggle-switch:focus-visible .toggle-switch__track {
    outline: 2px solid var(--accent-cyan);
    outline-offset: 2px;
}


.rebalancing-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.rebalancing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: var(--space-lg);
}

.rebalancing-status {
    position: fixed;
    bottom: var(--space-lg);
    right: var(--space-lg);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.rebalancing-status.connected {
    border-color: var(--green-primary);
}

.rebalancing-status.error {
    border-color: var(--red-primary);
}

/* ============================================
   GAP HORIZON METER
   ============================================ */
.gap-horizon {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.gap-horizon__header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.gap-horizon__title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Auto trade toggle in GapHorizon header */
.gap-horizon__auto-trade {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-left: auto;
}

.gap-horizon__auto-trade-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
    white-space: nowrap;
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    background: var(--green-bg);
    border: 1px solid var(--green-dim);
    border-radius: var(--radius-sm);
    color: var(--green-primary);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.live-indicator__dot {
    width: 8px;
    height: 8px;
    background: var(--green-primary);
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.9); }
}

.offline-indicator {
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    font-size: 0.75rem;
    font-weight: 500;
}

.gap-horizon__value {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
}

.gap-horizon__percent {
    font-family: var(--font-mono);
    font-size: 3rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.gap-horizon__percent.positive {
    color: var(--green-primary);
}

.gap-horizon__percent.negative {
    color: var(--red-primary);
}

.gap-horizon__direction {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.gap-horizon__track {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.gap-horizon__track-bg {
    position: relative;
    height: 48px;
    background: linear-gradient(90deg,
        var(--red-bg) 0%,
        var(--bg-tertiary) 50%,
        var(--green-bg) 100%
    );
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.gap-horizon__markers {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.gap-horizon__marker {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--border-default);
    transform: translateX(-50%);
}

.gap-horizon__marker.center {
    width: 2px;
    background: var(--text-tertiary);
}

.gap-horizon__beacon {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
    transition: left var(--transition-base);
}

.gap-horizon__beacon-dot {
    width: 24px;
    height: 24px;
    background: var(--accent-cyan);
    border: 3px solid var(--bg-primary);
    border-radius: 50%;
    box-shadow: 0 0 20px var(--accent-cyan), var(--shadow-md);
}

.gap-horizon__beacon-label {
    position: absolute;
    top: 100%;
    margin-top: var(--space-xs);
    padding: 2px 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-cyan);
    white-space: nowrap;
}

.gap-horizon__labels {
    display: flex;
    justify-content: space-between;
    padding: 0 var(--space-xs);
}

.gap-horizon__label {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.gap-horizon__market-data {
    display: flex;
    justify-content: center;
    gap: var(--space-xl);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-subtle);
}

.market-data__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
}

.market-data__label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
}

.market-data__value {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
}

.market-data__value--upbit {
    color: var(--upbit-primary);
}

.market-data__value--binance {
    color: var(--binance-primary);
}

/* Exchange rate refresh button */
.exchange-rate-refresh {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-left: var(--space-xs);
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s ease, color 0.2s ease, transform 0.2s ease;
    vertical-align: middle;
    line-height: 1;
}

.exchange-rate-refresh:hover:not(:disabled) {
    opacity: 1;
    color: var(--text-primary);
}

.exchange-rate-refresh:active:not(:disabled) {
    transform: scale(0.9);
}

.exchange-rate-refresh:disabled {
    cursor: not-allowed;
    opacity: 0.3;
}

.exchange-rate-refresh__icon {
    display: inline-block;
    font-size: 0.85rem;
    line-height: 1;
}

.exchange-rate-refresh__icon.spinning {
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ============================================
   SIGNAL CARD
   ============================================ */
.signal-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.signal-card.signal-rebalance {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 20px rgba(6, 182, 212, 0.1);
}

.signal-card.signal-hold {
    border-color: var(--green-dim);
}

.signal-card.signal-warning {
    border-color: var(--red-dim);
    animation: warning-pulse 2s ease-in-out infinite;
}

@keyframes warning-pulse {
    0%, 100% { box-shadow: 0 0 10px var(--red-glow); }
    50% { box-shadow: 0 0 25px var(--red-glow); }
}

.signal-card__badge {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.signal-card__type {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
}

.signal-rebalance .signal-card__type {
    color: var(--accent-cyan);
}

.signal-hold .signal-card__type {
    color: var(--green-primary);
}

.signal-warning .signal-card__type {
    color: var(--red-primary);
}

.signal-card__level {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text-secondary);
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.signal-card__ratios {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.signal-card__ratio {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.signal-card__ratio-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.signal-card__exchange {
    font-weight: 600;
    font-size: 0.9rem;
}

.signal-card__exchange--upbit {
    color: var(--upbit-primary);
}

.signal-card__exchange--binance {
    color: var(--binance-primary);
}

.signal-card__target {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

.signal-card__bar-container {
    position: relative;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    overflow: visible;
}

.signal-card__bar {
    height: 100%;
    border-radius: var(--radius-sm);
    transition: width var(--transition-base);
}

.signal-card__bar--upbit {
    background: linear-gradient(90deg, var(--upbit-secondary), var(--upbit-primary));
}

.signal-card__bar--binance {
    background: linear-gradient(90deg, var(--binance-secondary), var(--binance-primary));
}

.signal-card__bar-target {
    position: absolute;
    top: -4px;
    bottom: -4px;
    width: 2px;
    background: var(--text-primary);
    border-radius: 1px;
    transform: translateX(-50%);
}

.signal-card__values {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.signal-card__current {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.signal-card__delta {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-tertiary);
}

.signal-card__delta.positive {
    color: var(--green-primary);
    background: var(--green-bg);
}

.signal-card__delta.negative {
    color: var(--red-primary);
    background: var(--red-bg);
}

.signal-card__action {
    text-align: center;
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
}

.signal-card__action--rebalance {
    background: rgba(6, 182, 212, 0.1);
    color: var(--accent-cyan);
}

.signal-card__action--hold {
    background: var(--green-bg);
    color: var(--green-primary);
}

.signal-card__action--warning {
    background: var(--red-bg);
    color: var(--red-primary);
}

/* ============================================
   PORTFOLIO COMPARE
   ============================================ */
.portfolio-compare {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.portfolio-compare__title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.portfolio-compare__cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
}

.portfolio-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.portfolio-card--upbit {
    border-top: 3px solid var(--upbit-primary);
}

.portfolio-card--binance {
    border-top: 3px solid var(--binance-primary);
}

.portfolio-card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border-subtle);
}

.portfolio-card__exchange {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.portfolio-card__total {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.portfolio-card__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-xs) 0;
}

.portfolio-card__asset {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.portfolio-card__symbol {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.portfolio-card__amount {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.portfolio-card__value {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.portfolio-card__ratio-section {
    margin-top: var(--space-sm);
    padding-top: var(--space-sm);
    border-top: 1px solid var(--border-subtle);
}

.portfolio-card__ratio-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-bottom: var(--space-xs);
}

.portfolio-card__ratio-bar {
    position: relative;
    height: 6px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
}

.portfolio-card__ratio-fill {
    height: 100%;
    border-radius: var(--radius-sm);
    transition: width var(--transition-base);
}

.portfolio-card__ratio-fill--upbit {
    background: var(--upbit-primary);
}

.portfolio-card__ratio-fill--binance {
    background: var(--binance-primary);
}

.portfolio-card__ratio-target {
    position: absolute;
    top: -2px;
    bottom: -2px;
    width: 2px;
    background: var(--text-primary);
    border-radius: 1px;
    transform: translateX(-50%);
}

.portfolio-compare__total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.portfolio-compare__total-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.portfolio-compare__total-values {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.portfolio-compare__total-krw,
.portfolio-compare__total-usd {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.portfolio-compare__total-separator {
    color: var(--text-tertiary);
}

.portfolio-compare__invested {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.portfolio-compare__invested-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.portfolio-compare__invested-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.portfolio-compare__invested-value {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.portfolio-compare__invested-breakdown {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.85rem;
    color: var(--text-tertiary);
}

.portfolio-compare__invested-detail {
    font-family: var(--font-mono);
}

.portfolio-compare__invested-separator {
    color: var(--border-default);
}

/* ============================================
   TRADE HISTORY COMPONENT
   ============================================ */
.trade-history {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.trade-history__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
}

.trade-history__title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.trade-history__stats {
    display: flex;
    gap: var(--space-lg);
}

.trade-history__stat {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.trade-history__stat strong {
    color: var(--text-primary);
    font-weight: 600;
}

.trade-history__table-container {
    overflow-x: auto;
}

.trade-history__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.trade-history__table thead th {
    text-align: left;
    padding: var(--space-sm) var(--space-md);
    color: var(--text-tertiary);
    font-weight: 500;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-subtle);
}

.trade-history__table tbody td {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
}

.trade-history__row:last-child td {
    border-bottom: none;
}

.trade-history__row:hover {
    background: rgba(255, 255, 255, 0.02);
}

.trade-history__empty td {
    text-align: center;
    padding: var(--space-xl);
    color: var(--text-tertiary);
    font-style: italic;
}

.trade-history__time {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-tertiary);
}

.trade-history__exchange {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.trade-history__exchange--upbit {
    background: rgba(59, 130, 246, 0.2);
    color: var(--blue-primary);
}

.trade-history__exchange--binance {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.trade-history__side {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
}

.trade-buy {
    background: rgba(34, 197, 94, 0.15);
    color: var(--green-primary);
}

.trade-sell {
    background: rgba(239, 68, 68, 0.15);
    color: var(--red-primary);
}

.trade-history__amount,
.trade-history__price {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-primary);
}

.trade-history__level {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* ============================================
   RESPONSIVE - REBALANCING PAGE
   ============================================ */
@media (max-width: 992px) {
    .rebalancing-grid {
        grid-template-columns: 1fr;
    }

    .portfolio-compare__cards {
        grid-template-columns: 1fr;
    }

    .gap-horizon__percent {
        font-size: 2.5rem;
    }

    .gap-horizon__market-data {
        flex-wrap: wrap;
        gap: var(--space-md);
    }

    .trade-history__header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }

    .trade-history__table {
        font-size: 0.85rem;
    }
}

@media (max-width: 768px) {
    .rebalancing-page {
        padding: var(--space-md);
    }

    .rebalancing-section {
        padding: var(--space-md);
    }

    .gap-horizon__percent {
        font-size: 2rem;
    }

    .gap-horizon__track-bg {
        height: 40px;
    }

    .gap-horizon__beacon-dot {
        width: 20px;
        height: 20px;
    }

    .signal-card__type {
        font-size: 1.2rem;
    }

    .trade-history {
        padding: var(--space-md);
    }

    .trade-history__stats {
        flex-direction: column;
        gap: var(--space-xs);
    }

    .trade-history__table thead th,
    .trade-history__table tbody td {
        padding: var(--space-xs) var(--space-sm);
    }

    .trade-history__table {
        font-size: 0.8rem;
    }
}

/* ============================================
   SIMULATION DASHBOARD (UC4.2)
   ============================================ */
.sim-dashboard {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.sim-dashboard__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: var(--space-md);
}

.sim-dashboard__badges {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.sim-badge {
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sim-badge--simulation {
    background: var(--accent-purple);
    color: white;
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.4);
}

/* Session Info */
.session-info {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.session-info__row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.session-info__label {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    min-width: 80px;
}

.session-info__value {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.session-info__id {
    font-family: var(--font-mono);
    cursor: help;
}

.session-info__status {
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
}

.status-active {
    background: var(--green-bg);
    color: var(--green-primary);
}

.status-paused {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.status-completed {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

/* PnL Display */
.pnl-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-lg);
    padding: var(--space-lg);
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
}

.pnl-display.pnl-positive {
    border-color: var(--green-dim);
    background: linear-gradient(135deg, var(--bg-tertiary), var(--green-bg));
}

.pnl-display.pnl-negative {
    border-color: var(--red-dim);
    background: linear-gradient(135deg, var(--bg-tertiary), var(--red-bg));
}

.pnl-display.pnl-neutral {
    border-color: var(--border-default);
}

.pnl-display__absolute {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
}

.pnl-display__label {
    font-size: 0.85rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
}

.pnl-display__value {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 700;
}

.pnl-positive .pnl-display__value {
    color: var(--green-primary);
    text-shadow: 0 0 20px var(--green-glow);
}

.pnl-negative .pnl-display__value {
    color: var(--red-primary);
    text-shadow: 0 0 20px var(--red-glow);
}

.pnl-neutral .pnl-display__value {
    color: var(--text-secondary);
}

.pnl-display__percentage {
    display: flex;
    align-items: center;
}

.pnl-display__pct-value {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 600;
}

.pnl-positive .pnl-display__pct-value {
    color: var(--green-secondary);
}

.pnl-negative .pnl-display__pct-value {
    color: var(--red-secondary);
}

/* SimPortfolioCard */
.sim-portfolio-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.sim-portfolio-card__title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
}

.sim-portfolio-card__grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
}

.sim-portfolio-card__exchange {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: var(--space-md);
}

.sim-portfolio-card__exchange--upbit {
    border-top: 3px solid var(--upbit-primary);
}

.sim-portfolio-card__exchange--binance {
    border-top: 3px solid var(--binance-primary);
}

.sim-portfolio-card__exchange-header {
    margin-bottom: var(--space-sm);
}

.sim-portfolio-card__exchange-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.sim-portfolio-card__comparison {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.sim-portfolio-card__column {
    flex: 1;
}

.sim-portfolio-card__column-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-bottom: var(--space-xs);
}

.sim-portfolio-card__arrow {
    color: var(--text-tertiary);
    font-size: 1.2rem;
    padding: 0 var(--space-xs);
}

.sim-portfolio-card__assets {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sim-portfolio-card__asset {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sim-portfolio-card__symbol {
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

.sim-portfolio-card__amount {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-primary);
}

.sim-portfolio-card__weight {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding-top: var(--space-sm);
    border-top: 1px solid var(--border-subtle);
}

.sim-portfolio-card__weight-label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    min-width: 70px;
}

.sim-portfolio-card__weight-bar {
    flex: 1;
    height: 6px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.sim-portfolio-card__weight-fill {
    height: 100%;
    border-radius: var(--radius-sm);
    transition: width var(--transition-base);
}

.sim-portfolio-card__weight-fill--upbit {
    background: var(--upbit-primary);
}

.sim-portfolio-card__weight-fill--binance {
    background: var(--binance-primary);
}

.sim-portfolio-card__weight-value {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
    min-width: 45px;
    text-align: right;
}

/* Dashboard Actions */
.sim-dashboard__actions {
    display: flex;
    justify-content: center;
    padding-top: var(--space-md);
}

.sim-dashboard__terminate-btn {
    padding: var(--space-sm) var(--space-lg);
    background: var(--red-bg);
    border: 1px solid var(--red-dim);
    border-radius: var(--radius-md);
    color: var(--red-primary);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
}

.sim-dashboard__terminate-btn:hover {
    background: var(--red-primary);
    color: white;
}

/* ============================================
   SIMULATION TRADE LIST (UC4.3)
   ============================================ */
.sim-trade-list {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.sim-trade-list__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
}

.sim-trade-list__title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.sim-trade-list__stats {
    display: flex;
    gap: var(--space-lg);
}

.sim-trade-list__stat {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.sim-trade-list__stat strong {
    color: var(--text-primary);
    font-weight: 600;
}

.sim-trade-list__table-container {
    overflow-x: auto;
}

.sim-trade-list__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.sim-trade-list__table thead th {
    text-align: left;
    padding: var(--space-sm) var(--space-md);
    color: var(--text-tertiary);
    font-weight: 500;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-subtle);
}

.sim-trade-list__table tbody td {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
}

.sim-trade-list__row {
    cursor: pointer;
    transition: var(--transition-fast);
}

.sim-trade-list__row:hover {
    background: rgba(255, 255, 255, 0.02);
}

.sim-trade-list__row--expanded {
    background: var(--bg-tertiary);
}

.sim-trade-list__empty td {
    text-align: center;
    padding: var(--space-xl);
    color: var(--text-tertiary);
    font-style: italic;
}

.sim-trade-list__time {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-tertiary);
}

.sim-trade-list__exchange {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-upbit {
    background: rgba(0, 98, 223, 0.2);
    color: var(--upbit-primary);
}

.badge-binance {
    background: rgba(240, 185, 11, 0.2);
    color: var(--binance-primary);
}

.sim-trade-list__side {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
}

.sim-trade-list__amount,
.sim-trade-list__price {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-primary);
}

.sim-trade-list__level {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.sim-trade-list__gap {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-tertiary);
}

/* Details Row */
.sim-trade-list__details-row td {
    padding: 0;
    background: var(--bg-elevated);
}

.portfolio-after {
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.portfolio-after__title {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    margin-bottom: var(--space-xs);
}

.portfolio-after__grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
}

.portfolio-after__exchange {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.portfolio-after__exchange-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.portfolio-after__balances {
    display: flex;
    gap: var(--space-md);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Load More */
.sim-trade-list__load-more {
    display: flex;
    justify-content: center;
    padding-top: var(--space-md);
    margin-top: var(--space-md);
    border-top: 1px solid var(--border-subtle);
}

.sim-trade-list__load-more-btn {
    padding: var(--space-sm) var(--space-lg);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
}

.sim-trade-list__load-more-btn:hover:not(:disabled) {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.sim-trade-list__load-more-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   RESPONSIVE - SIMULATION COMPONENTS
   ============================================ */
@media (max-width: 992px) {
    .sim-portfolio-card__grid {
        grid-template-columns: 1fr;
    }

    .pnl-display {
        flex-direction: column;
        gap: var(--space-md);
    }

    .pnl-display__value {
        font-size: 1.75rem;
    }
}

@media (max-width: 768px) {
    .sim-dashboard__header {
        flex-direction: column;
        align-items: flex-start;
    }

    .sim-trade-list__header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }

    .sim-trade-list__table {
        font-size: 0.85rem;
    }

    .sim-trade-list__table thead th,
    .sim-trade-list__table tbody td {
        padding: var(--space-xs) var(--space-sm);
    }

    .portfolio-after__grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   SIMULATION SETUP FORM (UC4.1)
   ============================================ */
.sim-setup-form {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    max-width: 500px;
    margin: 0 auto;
}

.sim-setup-form__title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    letter-spacing: -0.02em;
    margin-bottom: var(--space-lg);
}

.sim-setup-form__error {
    background: var(--red-bg);
    border: 1px solid var(--red-dim);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    color: var(--red-primary);
    margin-bottom: var(--space-lg);
}

.sim-setup-form__presets {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
    justify-content: center;
}

.sim-setup-form__presets-label {
    width: 100%;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: var(--space-xs);
}

.sim-setup-form__preset-btn {
    position: relative;
    padding: var(--space-xs) var(--space-md);
    background: var(--bg-tertiary);
    border: 1px dashed var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-base);
}

.sim-setup-form__preset-btn:hover {
    border-style: solid;
    border-color: var(--green-primary);
    color: var(--green-primary);
    background: rgba(0, 245, 160, 0.05);
}

.sim-setup-form__preset-btn.active {
    background: var(--green-bg);
    border-color: var(--green-dim);
    color: var(--green-primary);
}

.sim-setup-form__exchange {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.sim-setup-form__exchange-legend {
    font-weight: 600;
    color: var(--text-primary);
    padding: 0 var(--space-sm);
}

.sim-setup-form__field {
    margin-bottom: var(--space-md);
}

.sim-setup-form__field:last-child {
    margin-bottom: 0;
}

.sim-setup-form__label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.sim-setup-form__required {
    color: var(--accent-cyan);
    margin-left: var(--space-xs);
}

.sim-setup-form__input {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    transition: var(--transition-fast);
}

.sim-setup-form__input:focus {
    outline: none;
    border-color: var(--green-primary);
    box-shadow: 0 0 0 2px var(--green-bg);
}

.sim-setup-form__input::placeholder {
    color: var(--text-muted);
}

.sim-setup-form__field-error {
    display: block;
    font-size: 0.8rem;
    color: var(--red-primary);
    margin-top: var(--space-xs);
}

.sim-setup-form__form-error {
    background: var(--red-bg);
    border: 1px solid var(--red-dim);
    border-radius: var(--radius-sm);
    padding: var(--space-sm) var(--space-md);
    color: var(--red-primary);
    font-size: 0.85rem;
    margin-bottom: var(--space-md);
}

.sim-setup-form__submit {
    width: 100%;
    padding: var(--space-md);
    background: linear-gradient(135deg, var(--green-primary), var(--green-secondary));
    border: none;
    border-radius: var(--radius-md);
    color: var(--bg-void);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-base);
}

.sim-setup-form__submit:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow-green);
}

.sim-setup-form__submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Simulation page layout */
.simulation-page {
    min-height: 100vh;
    padding: var(--space-lg);
}

.simulation-container {
    max-width: var(--content-max-width);
    margin: 0 auto;
}

/* Responsive - Simulation Setup Form */
@media (max-width: 768px) {
    .sim-setup-form {
        padding: var(--space-lg);
    }

    .sim-setup-form__title {
        font-size: 1.25rem;
    }

    .sim-setup-form__presets {
        flex-direction: column;
    }

    .sim-setup-form__preset-btn {
        width: 100%;
        text-align: center;
    }

    .sim-setup-form__exchange {
        padding: var(--space-md);
    }
}

/* ============================================
   LOADING CONTAINER (I1)
   ============================================ */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
    gap: var(--space-md);
    min-height: 400px;
    color: var(--text-secondary);
}

/* ============================================
   TABLE CAPTION (I3 - sr-only for accessibility)
   ============================================ */
table caption.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================
   SESSIONS LIST PAGE (UC4.4)
   ============================================ */
.sessions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
}

.sessions-header__title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.sessions-header__new-btn {
    padding: var(--space-sm) var(--space-lg);
    background: linear-gradient(135deg, var(--green-primary), var(--green-secondary));
    border: none;
    border-radius: var(--radius-md);
    color: var(--bg-void);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition-base);
}

.sessions-header__new-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow-green);
}

.sessions-filter {
    display: flex;
    gap: var(--space-xs);
    margin-bottom: var(--space-lg);
    padding: var(--space-xs);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.sessions-filter__tab {
    padding: var(--space-sm) var(--space-lg);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition-fast);
}

.sessions-filter__tab:hover {
    color: var(--text-primary);
}

.sessions-filter__tab.active {
    background: var(--accent-blue);
    color: white;
}

.sessions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--space-lg);
}

.sessions-empty {
    text-align: center;
    padding: var(--space-xl);
    color: var(--text-tertiary);
}

.sessions-empty__link {
    display: inline-block;
    margin-top: var(--space-md);
    color: var(--green-primary);
    text-decoration: none;
}

.sessions-empty__link:hover {
    text-decoration: underline;
}

.sessions-footer {
    margin-top: var(--space-lg);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-subtle);
    text-align: center;
}

.sessions-footer__count {
    color: var(--text-tertiary);
    font-size: 0.9rem;
}

/* Session Card */
.session-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    transition: var(--transition-base);
}

.session-card:hover {
    border-color: var(--border-default);
    box-shadow: var(--shadow-md);
}

.session-card__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-md);
}

.session-card__link {
    text-decoration: none;
}

.session-card__title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.session-card__link:hover .session-card__title {
    color: var(--accent-blue);
}

.session-card__status {
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.session-card__body {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    margin-bottom: var(--space-md);
}

.session-card__info {
    display: flex;
    gap: var(--space-sm);
    font-size: 0.85rem;
}

.session-card__label {
    color: var(--text-tertiary);
    min-width: 60px;
}

.session-card__value {
    color: var(--text-secondary);
}

.session-card__pnl {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-md);
}

.session-card__pnl.pnl-positive {
    background: var(--green-bg);
}

.session-card__pnl.pnl-negative {
    background: var(--red-bg);
}

.session-card__pnl.pnl-neutral {
    background: var(--bg-tertiary);
}

.session-card__pnl-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.session-card__pnl-value {
    font-family: var(--font-mono);
    font-weight: 600;
}

.session-card__pnl.pnl-positive .session-card__pnl-value {
    color: var(--green-primary);
}

.session-card__pnl.pnl-negative .session-card__pnl-value {
    color: var(--red-primary);
}

.session-card__pnl.pnl-neutral .session-card__pnl-value {
    color: var(--text-tertiary);
}

.session-card__actions {
    display: flex;
    gap: var(--space-sm);
}

.session-card__view-btn {
    flex: 1;
    padding: var(--space-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-align: center;
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition-fast);
}

.session-card__view-btn:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.session-card__delete-btn {
    padding: var(--space-sm);
    background: transparent;
    border: 1px solid var(--red-dim);
    border-radius: var(--radius-sm);
    color: var(--red-secondary);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition-fast);
}

.session-card__delete-btn:hover {
    background: var(--red-bg);
    color: var(--red-primary);
}

/* Delete Modal */
.delete-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.delete-modal__content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    max-width: 400px;
    text-align: center;
}

.delete-modal__content p {
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
}

.delete-modal__actions {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
}

.delete-modal__cancel {
    padding: var(--space-sm) var(--space-lg);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
}

.delete-modal__cancel:hover {
    background: var(--bg-elevated);
}

.delete-modal__confirm {
    padding: var(--space-sm) var(--space-lg);
    background: var(--red-primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    cursor: pointer;
}

.delete-modal__confirm:hover {
    background: var(--red-secondary);
}

/* Simulation loading/empty states */
.simulation-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    gap: var(--space-md);
    color: var(--text-secondary);
}

.simulation-empty {
    text-align: center;
    padding: var(--space-xl);
    color: var(--text-tertiary);
}

.simulation-empty__link {
    display: inline-block;
    margin-top: var(--space-md);
    color: var(--green-primary);
    text-decoration: none;
}

.simulation-empty__link:hover {
    text-decoration: underline;
}

/* Simulation content with aria-live */
.simulation-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
}

.simulation-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.simulation-status {
    position: fixed;
    bottom: var(--space-lg);
    right: var(--space-lg);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.simulation-status__label {
    color: var(--text-tertiary);
}

.simulation-status__value {
    color: var(--text-secondary);
}

.simulation-status__value.connected {
    color: var(--green-primary);
}

.simulation-status__value.error {
    color: var(--red-primary);
}

/* Rebalancing status connection states */
.rebalancing-status__label {
    color: var(--text-tertiary);
}

.rebalancing-status__value {
    color: var(--text-secondary);
}

.rebalancing-status__value.connected {
    color: var(--green-primary);
}

.rebalancing-status__value.error {
    color: var(--red-primary);
}

/* ============================================
   LOGIN PAGE
   ============================================ */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-void);
    padding: var(--space-lg);
}

.login-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    width: 100%;
    max-width: 400px;
}

.login-container h1 {
    font-family: var(--font-ui);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    letter-spacing: -0.02em;
    margin-bottom: var(--space-sm);
}

.login-container h1::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--green-primary);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--green-glow);
    margin-right: var(--space-sm);
    vertical-align: middle;
}

.login-container h2 {
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: var(--space-xl);
}

.error-message {
    background: var(--red-bg);
    border: 1px solid var(--red-dim);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    color: var(--red-primary);
    font-size: 0.85rem;
    margin-bottom: var(--space-lg);
}

.form-group {
    margin-bottom: var(--space-md);
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.form-group input {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    transition: var(--transition-fast);
}

.form-group input:focus {
    outline: none;
    border-color: var(--green-primary);
    box-shadow: 0 0 0 2px var(--green-bg);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.login-container button[type="submit"] {
    width: 100%;
    padding: var(--space-md);
    background: linear-gradient(135deg, var(--green-primary), var(--green-secondary));
    border: none;
    border-radius: var(--radius-md);
    color: var(--bg-void);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-base);
    margin-top: var(--space-sm);
}

.login-container button[type="submit"]:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow-green);
}

.login-container button[type="submit"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.toggle-form {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: var(--space-lg);
}

.toggle-form a {
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition-fast);
}

.toggle-form a:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

/* ============================================
   HEADER USER SECTION
   ============================================ */

.header-user {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.username {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

.logout-btn {
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.logout-btn:hover {
    border-color: var(--red-primary);
    color: var(--red-primary);
    background: var(--red-bg);
}

/* Responsive - Login Page */
@media (max-width: 768px) {
    .login-container {
        padding: var(--space-lg);
    }

    .login-container h1 {
        font-size: 1.25rem;
    }
}

/* ============================================
   ACCOUNT SETTINGS PAGE - Phase 5
   ============================================ */

.account-page {
    min-height: 100vh;
    background: var(--bg-void);
    padding-top: var(--space-lg);
}

.account-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

.account-header {
    margin-bottom: var(--space-xl);
}

.account-header h1 {
    font-family: var(--font-ui);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.account-header__subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: var(--space-xs);
}

.account-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
}

/* Exchange Keys Section */
.exchange-keys-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.exchange-keys-section__title {
    font-family: var(--font-ui);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
}

.key-cards-grid {
    display: grid;
    gap: var(--space-md);
}

/* Key Card */
.key-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-default);
    border-left: 3px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    transition: var(--transition-base);
}

.key-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
}

.key-card--binance {
    border-left-color: var(--binance-primary);
}

.key-card--upbit {
    border-left-color: var(--upbit-primary);
}

.key-card--bithumb {
    border-left-color: var(--bithumb-primary);
}

.key-card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
}

.key-card__exchange {
    font-family: var(--font-ui);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.key-card--binance .key-card__exchange {
    color: var(--binance-primary);
}

.key-card--upbit .key-card__exchange {
    color: var(--upbit-primary);
}

.key-card--bithumb .key-card__exchange {
    color: var(--bithumb-primary);
}

.key-card__delete {
    padding: var(--space-xs) var(--space-sm);
    background: transparent;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.key-card__delete:hover {
    border-color: var(--red-primary);
    color: var(--red-primary);
    background: var(--red-bg);
}

.key-card__body {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.key-card__field {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.key-card__label {
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

.key-card__value {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Key Form */
.key-form {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.key-form__title {
    font-family: var(--font-ui);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
}

.key-form select {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    transition: var(--transition-fast);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238892a2' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-md) center;
    cursor: pointer;
}

.key-form select:focus {
    outline: none;
    border-color: var(--green-primary);
    box-shadow: 0 0 0 2px var(--green-bg);
}

.key-form__submit {
    width: 100%;
    padding: var(--space-md);
    background: linear-gradient(135deg, var(--green-primary), var(--green-secondary));
    border: none;
    border-radius: var(--radius-md);
    color: var(--bg-void);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-base);
    margin-top: var(--space-sm);
}

.key-form__submit:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow-green);
}

.key-form__submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Success Message */
.success-message {
    background: var(--green-bg);
    border: 1px solid var(--green-dim);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    color: var(--green-primary);
    font-size: 0.85rem;
    margin-bottom: var(--space-md);
}

/* API Key Notice (Rebalancing Page) */
.api-key-notice {
    background: rgba(240, 185, 11, 0.08);
    border: 1px solid rgba(240, 185, 11, 0.3);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
}

.api-key-notice__text {
    font-size: 0.85rem;
    color: var(--binance-primary);
    line-height: 1.5;
}

.api-key-notice a {
    color: var(--green-primary);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition-fast);
}

.api-key-notice a:hover {
    text-decoration: underline;
}

/* Responsive - Account Page */
@media (max-width: 768px) {
    .account-container {
        padding: 0 var(--space-md);
    }

    .account-header h1 {
        font-size: 1.25rem;
    }

    .exchange-keys-section,
    .key-form {
        padding: var(--space-md);
    }

    .key-card__field {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }
}

/* ============================================
   KRW EXCHANGE GENERIC VARIANTS
   These --krw classes apply to whichever KRW exchange is selected.
   They inherit the upbit primary color as default since the UI
   dynamically displays the exchange name via auth context.
   ============================================ */

/* Market data */
.market-data__value--krw {
    color: var(--upbit-primary);
}

/* Signal card */
.signal-card__exchange--krw {
    color: var(--upbit-primary);
}

.signal-card__bar--krw {
    background: linear-gradient(90deg, var(--upbit-secondary), var(--upbit-primary));
}

/* Portfolio card */
.portfolio-card--krw {
    border-top: 3px solid var(--upbit-primary);
}

.portfolio-card__ratio-fill--krw {
    background: var(--upbit-primary);
}

/* Trade history: bithumb exchange badge */
.trade-history__exchange--bithumb {
    background: rgba(243, 115, 33, 0.2);
    color: var(--bithumb-primary);
}

/* ============================================
   KRW EXCHANGE SELECTOR (Account Page)
   ============================================ */

.krw-exchange-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.krw-exchange-section__title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.krw-exchange-section__description {
    font-size: 0.85rem;
    color: var(--text-tertiary);
    margin-bottom: var(--space-md);
}

.krw-exchange-selector {
    display: flex;
    gap: var(--space-md);
    align-items: center;
}

.krw-exchange-option {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    background: var(--bg-tertiary);
}

.krw-exchange-option:hover {
    border-color: var(--border-default);
    background: var(--bg-secondary);
}

.krw-exchange-option.active {
    border-color: var(--blue-primary);
    background: rgba(59, 130, 246, 0.1);
}

.krw-exchange-option input[type="radio"] {
    accent-color: var(--blue-primary);
}

.krw-exchange-option__label {
    font-weight: 500;
    color: var(--text-primary);
}

.krw-exchange-saving {
    font-size: 0.85rem;
    color: var(--text-tertiary);
    font-style: italic;
}
