:root {
    --bg: #070b12;
    --panel: #0f1623;
    --panel-2: #101b2b;
    --surface: #152238;
    --line: #22324f;
    --line-soft: #1a2941;
    --text: #e6eefb;
    --muted: #8fa4c9;
    --cyan: #15c7d8;
    --blue: #2b86ff;
    --pos: #1fd88f;
    --neg: #ff5f7a;
    --warn: #f5c059;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Pretendard", "SUIT", "Noto Sans KR", "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(1200px 500px at 10% -10%, rgba(43, 134, 255, 0.15), transparent 55%),
        radial-gradient(1000px 480px at 100% 0%, rgba(21, 199, 216, 0.12), transparent 58%),
        var(--bg);
}

.app-shell {
    width: min(1400px, calc(100% - 32px));
    margin: 20px auto 40px;
    display: grid;
    gap: 16px;
}

.hero-panel,
.panel,
.kpi-card,
.foot-cards article {
    border: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(16, 27, 43, 0.94), rgba(10, 16, 28, 0.94));
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.hero-panel {
    padding: 18px 20px;
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 20px;
    align-items: end;
}

.brand {
    display: inline-flex;
    align-items: center;
    height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    background: rgba(43, 134, 255, 0.16);
    color: #c9dcff;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.03em;
}

.brand-block h1 {
    margin: 10px 0 8px;
    font-size: clamp(24px, 2.6vw, 34px);
    line-height: 1.2;
}

.brand-block p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.hero-status {
    display: grid;
    gap: 10px;
    justify-items: end;
}

.live-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.live-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 56px;
    height: 28px;
    border-radius: 999px;
    background: rgba(31, 216, 143, 0.18);
    border: 1px solid rgba(31, 216, 143, 0.4);
    color: #8df4ca;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.live-badge.offline {
    background: rgba(255, 95, 122, 0.12);
    border-color: rgba(255, 95, 122, 0.35);
    color: #ff98ac;
}

.status-text,
.status-line {
    color: var(--muted);
    font-size: 13px;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 12px;
}

.kpi-card {
    padding: 14px 14px 12px;
    min-height: 96px;
    display: grid;
    align-content: space-between;
}

.kpi-label {
    color: var(--muted);
    font-size: 12px;
}

.kpi-value {
    font-size: clamp(20px, 2.1vw, 30px);
    font-weight: 700;
    letter-spacing: -0.01em;
}

.kpi-pair {
    font-size: 17px;
    line-height: 1.3;
}

.panel {
    padding: 16px;
}

.section-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.section-head h2 {
    margin: 0;
    font-size: 20px;
}

.section-head p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.control-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.exchange-select-group {
    display: grid;
    gap: 6px;
    min-width: 180px;
}

.exchange-select-group.compact {
    min-width: 150px;
}

.exchange-select-group label {
    font-size: 12px;
    color: var(--muted);
}

.exchange-select-group select,
.custom-select-trigger {
    width: 100%;
    height: 40px;
    background: #0c1422;
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 10px;
    padding: 0 36px 0 12px;
    font-size: 13px;
}

.exchange-select-group select:focus,
.custom-select-trigger:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(43, 134, 255, 0.2);
}

.selected-exchange-pair {
    color: #b8d2ff;
    font-size: 13px;
}

.chart-container {
    height: 440px;
    border: 1px solid var(--line-soft);
    border-radius: 12px;
    overflow: hidden;
    background: #0b1220;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line-soft);
    border-radius: 12px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 860px;
}

thead {
    background: #0d1728;
}

th, td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--line-soft);
    text-align: left;
    font-size: 14px;
    vertical-align: middle;
}

th {
    color: #9fb3d9;
    font-size: 12px;
    letter-spacing: 0.02em;
    font-weight: 600;
}

th.sortable {
    cursor: pointer;
    user-select: none;
}

tbody tr[data-symbol] {
    transition: background-color 0.18s ease;
    cursor: pointer;
}

tbody tr[data-symbol]:hover {
    background: rgba(43, 134, 255, 0.08);
}

tr.active-row {
    background: rgba(21, 199, 216, 0.09);
}

.main-value { font-weight: 600; }
.sub-value { margin-top: 3px; color: var(--muted); font-size: 12px; }

.cell-num { text-align: right; }
.cell-num .main-value, .cell-num .sub-value { text-align: right; }

.coin-row-main {
    display: inline-flex;
    align-items: center;
    gap: 9px;
}

.coin-logo {
    width: 21px;
    height: 21px;
    border-radius: 50%;
    border: 1px solid #2e446c;
    background: #081120;
}

.tone-positive { color: var(--pos); }
.tone-negative { color: var(--neg); }
.tone-neutral { color: var(--text); }

.detail-row td {
    background: #0b1422;
    padding: 12px;
}

.detail-panel {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    background: #0a1320;
    display: grid;
    gap: 12px;
}

.detail-status-grid,
.detail-chart-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.exchange-status-card,
.pair-chart-box {
    border: 1px solid var(--line-soft);
    background: #0d1728;
    border-radius: 10px;
    padding: 10px;
}

.exchange-status-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.exchange-name-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.exchange-logo-wrap,
.exchange-logo-fallback {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #0d223a;
    border: 1px solid #32557d;
    font-size: 10px;
    font-weight: 700;
}

.exchange-logo-img-inline {
    width: 18px;
    height: 18px;
    object-fit: cover;
    border-radius: 50%;
}

.summary-badges,
.network-badges,
.detail-intervals {
    display: inline-flex;
    gap: 6px;
    flex-wrap: wrap;
}

.network-badge,
.detail-interval-btn {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 11px;
    color: #c9d8f3;
    background: rgba(143, 164, 201, 0.08);
}

.detail-interval-btn {
    cursor: pointer;
    background: #0d1728;
}

.detail-interval-btn.active {
    border-color: #2d8fff;
    color: #cbe0ff;
    background: rgba(45, 143, 255, 0.15);
}

.status-on { color: #9cf5d0; border-color: rgba(31, 216, 143, 0.5); }
.status-off { color: #ff9fb0; border-color: rgba(255, 95, 122, 0.5); }
.status-unknown { color: #ffdca2; border-color: rgba(245, 192, 89, 0.5); }

.network-line {
    margin-top: 8px;
    display: grid;
    gap: 6px;
}

.network-label,
.network-name,
.network-empty,
.pair-chart-box h4 {
    color: var(--muted);
    font-size: 12px;
    margin: 0;
}

.network-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 0;
}

.network-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    border: 1px solid transparent;
}

.network-dot.status-on { background: var(--pos); }
.network-dot.status-off { background: var(--neg); }
.network-dot.status-unknown { background: var(--warn); }

.pair-chart-container,
.pair-chart-iframe {
    width: 100%;
    min-height: 300px;
    border: 0;
    border-radius: 8px;
    overflow: hidden;
    display: block;
    background: #0b1220;
}

.foot-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.foot-cards article {
    padding: 14px;
}

.foot-cards h3 {
    margin: 0 0 6px;
    font-size: 15px;
}

.foot-cards p {
    margin: 0;
    font-size: 13px;
    color: var(--muted);
    line-height: 1.5;
}

.legacy-hidden {
    display: none;
}

.native-hidden-select {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.custom-select {
    position: relative;
}

.custom-select-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    text-align: left;
    position: relative;
}

.custom-select-trigger::after {
    content: "▾";
    position: absolute;
    right: 12px;
    color: #9eb4db;
    pointer-events: none;
}

.custom-select-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #0d1728;
    border: 1px solid var(--line);
    border-radius: 10px;
    max-height: 280px;
    overflow-y: auto;
    z-index: 50;
    display: none;
}

.custom-select.open .custom-select-menu {
    display: block;
}

.custom-select-option {
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--text);
    padding: 9px 10px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.custom-select-option:hover,
.custom-select-option.active {
    background: rgba(43, 134, 255, 0.18);
}

.custom-select-logo-wrap {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.custom-select-logo {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid #365885;
    background: #0b1728;
}

@media (max-width: 1200px) {
    .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .hero-panel { grid-template-columns: 1fr; align-items: start; }
    .hero-status { justify-items: start; }
}

@media (max-width: 768px) {
    .app-shell { width: calc(100% - 20px); margin: 10px auto 24px; gap: 12px; }
    .panel { padding: 12px; }
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .section-head { flex-direction: column; align-items: start; }
    .control-row { width: 100%; }
    .exchange-select-group { width: 100%; }
    .chart-container { height: 330px; }
    .detail-status-grid,
    .detail-chart-grid,
    .foot-cards { grid-template-columns: 1fr; }
}
