﻿@import url("https://cdn.jsdelivr.net/gh/sunn-us/SUIT/fonts/static/woff2/SUIT.css");

:root {
    --bg-a: #fff8eb;
    --bg-b: #dff4eb;
    --panel: rgba(255, 255, 255, 0.78);
    --text: #1f2a36;
    --muted: #5b6875;
    --line: #d7deda;
    --accent: #ff6b2c;
    --accent-deep: #d64912;
    --up: #1d8a5d;
    --down: #cc3c2e;
    --flat: #5d6a77;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--text);
    font-family: "SUIT", "Pretendard", sans-serif;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--bg-a), var(--bg-b));
}

.background-layer {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 12% 12%, rgba(255, 107, 44, 0.22), transparent 36%),
        radial-gradient(circle at 86% 20%, rgba(34, 177, 129, 0.2), transparent 34%),
        radial-gradient(circle at 50% 84%, rgba(255, 193, 107, 0.2), transparent 40%);
    pointer-events: none;
}

.page {
    position: relative;
    z-index: 1;
    max-width: 1180px;
    margin: 0 auto;
    padding: 32px 20px 40px;
    display: grid;
    gap: 16px;
}

.panel {
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--panel);
    backdrop-filter: blur(7px);
    box-shadow: 0 12px 30px rgba(18, 31, 36, 0.07);
}

.hero {
    padding: 24px;
}

.eyebrow {
    margin: 0;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--accent-deep);
    font-size: 12px;
}

.hero h1 {
    margin: 8px 0 10px;
    font-size: clamp(28px, 4vw, 42px);
    line-height: 1.1;
}

.hero-copy {
    margin: 0;
    color: var(--muted);
}

.hero-meta {
    margin-top: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    font-size: 14px;
}

.refresh-button {
    margin-top: 16px;
    border: none;
    border-radius: 999px;
    background: linear-gradient(120deg, var(--accent), #ff9656);
    color: #fff;
    font-weight: 700;
    padding: 10px 18px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.refresh-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(255, 107, 44, 0.3);
}

.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1.35fr;
    gap: 12px;
}

.summary-card {
    padding: 18px;
}

.summary-card p {
    margin: 0;
    color: var(--muted);
    font-weight: 600;
    font-size: 13px;
}

.summary-card h2 {
    margin: 10px 0 0;
    font-size: clamp(24px, 2.7vw, 34px);
    line-height: 1;
}

#topTradingValueSpacValue {
    white-space: nowrap;
    font-size: clamp(20px, 2.2vw, 30px);
}

.table-panel {
    padding: 16px;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 12px;
}

.table-header h3 {
    margin: 0;
    font-size: 20px;
}

.caption {
    color: var(--muted);
    font-size: 13px;
}

.table-wrap {
    overflow-x: auto;
}

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

th,
td {
    padding: 13px 12px;
    border-bottom: 1px solid var(--line);
}

th {
    text-align: left;
    font-size: 13px;
    color: var(--muted);
    font-weight: 700;
}

.sort-button {
    width: 100%;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0;
    border: none;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.sort-button.num {
    justify-content: flex-end;
}

.sort-button.active {
    color: var(--text);
}

tbody tr {
    animation: rise 0.45s ease both;
    animation-delay: calc(var(--row, 0) * 0.03s);
}

td {
    font-size: 14px;
    font-weight: 600;
}

.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.code {
    color: var(--muted);
    font-family: "D2Coding", "Consolas", monospace;
}

.stock-link {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.stock-link:hover {
    color: var(--accent-deep);
    border-bottom-color: var(--accent-deep);
}

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

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

.flat {
    color: var(--flat);
}

.empty {
    text-align: center;
    color: var(--muted);
    font-weight: 500;
}

.fade-in {
    animation: fadeIn 0.6s ease both;
}

.reveal {
    opacity: 0;
    animation: fadeIn 0.6s ease forwards;
    animation-delay: var(--delay, 0s);
}

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

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 980px) {
    .page {
        padding: 28px 16px 32px;
    }

    .summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .table-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 760px) {
    .page {
        padding: 22px 12px 26px;
        gap: 12px;
    }

    .hero {
        padding: 18px;
    }

    .summary-grid {
        grid-template-columns: 1fr;
    }

    #topTradingValueSpacValue {
        white-space: normal;
    }

    .table-panel {
        padding: 12px;
    }

    .hero-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .table-wrap {
        overflow: visible;
    }

    table {
        min-width: 0;
    }

    thead {
        display: block;
        margin-bottom: 10px;
    }

    thead tr {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        padding-bottom: 2px;
    }

    th {
        display: block;
        padding: 0;
        border-bottom: none;
        flex: 0 0 auto;
    }

    .sort-button {
        width: auto;
        padding: 9px 12px;
        border: 1px solid var(--line);
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.88);
        white-space: nowrap;
    }

    .sort-button.num {
        justify-content: center;
    }

    tbody {
        display: grid;
        gap: 12px;
    }

    tbody tr {
        display: grid;
        border: 1px solid var(--line);
        border-radius: 16px;
        overflow: hidden;
        background: rgba(255, 255, 255, 0.9);
        box-shadow: 0 10px 22px rgba(18, 31, 36, 0.05);
    }

    td {
        display: grid;
        grid-template-columns: 88px minmax(0, 1fr);
        gap: 10px;
        padding: 11px 12px;
        border-bottom: 1px solid rgba(215, 222, 218, 0.85);
        font-size: 14px;
    }

    td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 12px;
        font-weight: 700;
    }

    td.num {
        text-align: left;
    }

    td:first-child {
        padding-top: 14px;
    }

    td:last-child {
        border-bottom: none;
        padding-bottom: 14px;
    }

    td[data-label="주식명"] {
        grid-template-columns: 1fr;
        gap: 6px;
        padding-bottom: 8px;
    }

    td[data-label="주식명"] .stock-link {
        font-size: 16px;
        font-weight: 800;
    }

    td.empty {
        display: block;
        padding: 24px 12px;
        border-bottom: none;
    }

    .code {
        word-break: break-all;
    }
}

@media (max-width: 480px) {
    .page {
        padding: 18px 10px 24px;
    }

    .summary-card {
        padding: 16px;
    }

    td {
        grid-template-columns: 76px minmax(0, 1fr);
        padding-inline: 10px;
    }

    .sort-button {
        padding: 8px 11px;
        font-size: 13px;
    }
}
