/* 심따리 다크 테마 */
:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-tertiary: #1a2235;
    --border: #243049;
    --text-primary: #e8edf5;
    --text-secondary: #8b97b0;
    --text-muted: #5a6478;
    --accent-green: #22c55e;
    --accent-red: #ef4444;
    --accent-yellow: #eab308;
    --accent-blue: #3b82f6;
    --accent-orange: #f97316;
    --accent-purple: #a855f7;
    --row-hover: #1e293b;
    --alert-1: rgba(34, 197, 94, 0.08);
    --alert-2: rgba(34, 197, 94, 0.15);
    --alert-3: rgba(234, 179, 8, 0.15);
    --alert-4: rgba(249, 115, 22, 0.2);
    --alert-5: rgba(239, 68, 68, 0.25);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    overflow-x: hidden;
}

/* 헤더 */
#header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: 50px;
    flex-wrap: wrap;
    gap: 10px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-left h1 {
    font-size: 20px;
    font-weight: 800;
    color: var(--accent-blue);
    letter-spacing: -0.5px;
}

.header-left .version {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 400;
}

.usdt-rate {
    font-size: 14px;
    color: var(--accent-yellow);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.header-center {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* 필터 버튼 */
.filter-group {
    display: flex;
    gap: 1px;
    background: var(--border);
    border-radius: 8px;
    padding: 1px;
    overflow: hidden;
}

.filter-btn {
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-muted);
    padding: 5px 12px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.15s;
    white-space: nowrap;
}

.filter-btn:first-child { border-radius: 7px 0 0 7px; }
.filter-btn:last-child { border-radius: 0 7px 7px 0; }

.filter-btn:hover {
    color: var(--text-primary);
    background: rgba(59, 130, 246, 0.15);
}

.filter-btn.active {
    background: var(--accent-blue);
    color: #fff;
}

/* 거래소 상태 */
.status-dots {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.exchange-dot {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 2px 4px;
    border-radius: 4px;
}

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

.dot.on { background: var(--accent-green); box-shadow: 0 0 4px var(--accent-green); }
.dot.off { background: var(--accent-red); }

.header-right {
    display: flex;
    gap: 8px;
}

.header-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 5px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.15s;
}

.header-btn:hover { background: var(--border); }
.header-btn.sound-off { opacity: 0.4; }

/* 거래소 아이콘 */
img.ex-icon {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    vertical-align: middle;
}

span.ex-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    font-size: 7px;
    font-weight: 800;
    color: #000;
    line-height: 1;
    vertical-align: middle;
}

.ex-bitget { background: #00F0FF; }

/* 메인 */
#main {
    display: flex;
    flex-direction: row;
    gap: 6px;
    padding: 8px;
    height: calc(100vh - 50px);
}

.arb-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    min-width: 0;
    min-height: 0;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.section-header h2 {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.item-count {
    background: var(--accent-blue);
    color: #fff;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    min-width: 28px;
    text-align: center;
}

.table-wrap {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.table-wrap::-webkit-scrollbar { width: 4px; }
.table-wrap::-webkit-scrollbar-track { background: transparent; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

thead th {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 1px;
}

thead th.col-from { width: 32%; text-align: left; }
thead th.col-to { width: 32%; text-align: left; }
thead th.col-amount { width: 20%; text-align: right; }
thead th.col-per { width: 16%; text-align: right; }

tbody tr {
    border-bottom: 1px solid rgba(36, 48, 73, 0.6);
    transition: background 0.1s;
    cursor: default;
}

tbody tr:hover {
    background: var(--row-hover);
}

tbody td {
    padding: 12px 10px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    font-size: 12px;
    line-height: 1.6;
}

td.col-from, td.col-to {
    text-align: left;
}

td.col-from img.ex-icon,
td.col-from span.ex-icon,
td.col-to img.ex-icon,
td.col-to span.ex-icon {
    margin-right: 6px;
}

.pair-label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 12px;
    letter-spacing: -0.2px;
}

td.col-amount {
    text-align: right;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
}

td.col-per {
    text-align: right;
    font-weight: 700;
    font-size: 12px;
}

/* 차익 색상 */
.diff-red { color: #ff4444; }
.diff-orange { color: #ff9900; }
.diff-green { color: #00cc66; }
.diff-white { color: #ffffff; }

/* 알림 레벨 행 */
tr.alert-1 { background: var(--alert-1); }
tr.alert-2 { background: var(--alert-2); }
tr.alert-3 { background: var(--alert-3); }
tr.alert-4 { background: var(--alert-4); }
tr.alert-5 { background: var(--alert-5); }
tr.alert-5 td.col-per { animation: pulse 1s infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* 컨텍스트 메뉴 */
.context-menu {
    position: fixed;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px 0;
    z-index: 1000;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    min-width: 150px;
}

.menu-item {
    padding: 8px 16px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.1s;
}

.menu-item:hover {
    background: var(--accent-blue);
    color: #fff;
}

/* 모달 */
.modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 14px;
    width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 16px; font-weight: 700; }

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
}

.modal-body { padding: 18px; }

.setting-group { margin-bottom: 20px; }

.setting-group h4 {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.ignored-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ignored-chip {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 12px;
}

.ignored-chip .remove {
    cursor: pointer;
    color: var(--accent-red);
    font-weight: 700;
}

.no-data {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
    font-size: 12px;
}

/* 죽은 데이터 (오래된 호가) */
tr.data-old {
    opacity: 0.5;
}

tr.data-stale {
    opacity: 0.25;
}

/* 코인 그룹 구분선 */
tr.group-top td {
    border-top: 2px solid var(--border) !important;
}
