@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+KR:wght@400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
    --bg-0: #f6f8fc;
    --bg-1: #eef2f9;
    --surface: #ffffff;
    --surface-soft: #f9fbff;
    --surface-strong: #f1f5fd;
    --ink: #111c2f;
    --ink-muted: #5a6f8d;
    --line: rgba(31, 56, 98, 0.14);
    --line-strong: rgba(31, 56, 98, 0.26);
    --accent: #1e4ea8;
    --accent-2: #0f7d9c;
    --premium: #b58a43;
    --premium-soft: #e8d3a6;
    --good: #067a5b;
    --bad: #cc3d3d;
    --glow: 0 24px 56px rgba(14, 28, 58, 0.16);
    --glow-soft: 0 12px 30px rgba(14, 28, 58, 0.11);
    --radius: 18px;
    --radius-sm: 10px;
    --hairline: rgba(255, 255, 255, 0.06);
}

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

body {
    font-family: 'IBM Plex Sans KR', 'Segoe UI', sans-serif;
    color: var(--ink);
    min-height: 100vh;
    padding: 12px;
    background:
        radial-gradient(1200px 760px at 16% -8%, rgba(19, 83, 174, 0.10) 0%, rgba(19, 83, 174, 0) 62%),
        radial-gradient(980px 660px at 88% -12%, rgba(181, 138, 67, 0.08) 0%, rgba(181, 138, 67, 0) 60%),
        radial-gradient(700px 480px at 48% 112%, rgba(27, 114, 146, 0.08) 0%, rgba(27, 114, 146, 0) 60%),
        linear-gradient(180deg, var(--bg-0), var(--bg-1));
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    border-radius: 24px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid rgba(188, 202, 225, 0.72);
    box-shadow: var(--glow);
    backdrop-filter: blur(10px);
}

.site-header {
    position: relative;
    overflow: hidden;
    padding: 20px 18px;
    background:
        linear-gradient(120deg, #f9fbff 0%, #eff5ff 52%, #e8f0fb 100%);
    color: #173764;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid rgba(188, 202, 225, 0.72);
}

.site-header::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(940px 420px at 50% -30%, rgba(255, 255, 255, 0.92) 0%, rgba(255, 255, 255, 0) 60%),
        linear-gradient(90deg, rgba(181, 138, 67, 0.12) 0%, rgba(181, 138, 67, 0) 16%, rgba(181, 138, 67, 0) 84%, rgba(181, 138, 67, 0.12) 100%),
        repeating-linear-gradient(90deg, rgba(30, 78, 168, 0.045) 0px, rgba(30, 78, 168, 0.045) 1px, rgba(30, 78, 168, 0) 1px, rgba(30, 78, 168, 0) 24px);
    pointer-events: none;
}

.site-header .logo-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 0;
}

.site-header .site-logo {
    max-width: 440px;
    width: min(82vw, 440px);
    height: auto;
    filter: drop-shadow(0 8px 18px rgba(37, 99, 235, 0.18));
}

.site-header p {
    display: none;
}

.auth-chip-wrap {
    position: absolute;
    top: 16px;
    left: 14px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    border-radius: 999px;
    border: 1px solid rgba(19, 52, 97, 0.16);
    background: rgba(255, 255, 255, 0.92);
}

.auth-role-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 56px;
    min-height: 24px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: #f8fbff;
}

.auth-role-badge.role-guest {
    background: #74839a;
}

.auth-role-badge.role-basic {
    background: #1e4ea8;
}

.auth-role-badge.role-pro {
    background: #0f7d9c;
}

.auth-user-email {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.76rem;
    font-weight: 600;
    color: #2f4a6e;
}

.auth-chip-btn {
    border: none;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #f8fbff;
    background: linear-gradient(135deg, #1a4288 0%, #1e4ea8 54%, #0f7d9c 100%);
    cursor: pointer;
}

.auth-chip-btn.ghost {
    background: #dde7f5;
    color: #233b5a;
}

.auth-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
}

.auth-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 22, 42, 0.42);
}

.auth-modal-card {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(92vw, 420px);
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid rgba(32, 66, 112, 0.18);
    padding: 16px;
    box-shadow: 0 20px 38px rgba(15, 34, 66, 0.28);
    display: grid;
    gap: 8px;
}

.auth-modal-card h3 {
    margin: 0;
    font-size: 1.1rem;
}

.auth-mode-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.auth-mode-tab {
    border: 1px solid rgba(30, 78, 168, 0.22);
    border-radius: 999px;
    min-height: 34px;
    font-size: 0.84rem;
    font-weight: 700;
    color: #2d4f78;
    background: #f5f9ff;
    cursor: pointer;
}

.auth-mode-tab.active {
    color: #f8fbff;
    background: linear-gradient(135deg, #1a4288 0%, #1e4ea8 54%, #0f7d9c 100%);
    border-color: transparent;
}

.auth-modal-desc {
    color: #4a6483;
    font-size: 0.9rem;
}

.auth-optional {
    display: grid;
    gap: 6px;
}

.auth-modal-card label {
    font-size: 0.82rem;
    color: #2e4a6f;
    font-weight: 700;
}

.auth-modal-card input {
    min-height: 40px;
    border: 1px solid #c7d7ea;
    border-radius: 10px;
    padding: 0 10px;
    font-size: 0.92rem;
}

.auth-modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 4px;
}

.auth-secondary-btn {
    border: 1px solid rgba(30, 78, 168, 0.32);
    border-radius: 12px;
    min-height: 42px;
    color: #1e4ea8;
    background: #f7fbff;
    font-size: 0.93rem;
    font-weight: 700;
    cursor: pointer;
}

.auth-message {
    min-height: 20px;
    font-size: 0.82rem;
    color: #35567d;
}

.auth-agree {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: #375678;
}

.auth-agree input {
    width: 15px;
    height: 15px;
    min-height: 15px;
}

.header-cta {
    position: absolute;
    top: 18px;
    right: 16px;
    z-index: 2;
    min-height: 36px;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #f8fbff;
    text-decoration: none;
    background: linear-gradient(135deg, #1a4288 0%, #1e4ea8 54%, #0f7d9c 100%);
    box-shadow: 0 8px 18px rgba(16, 47, 96, 0.24);
}

.header-donate-cta {
    position: absolute;
    top: 18px;
    right: 150px;
    z-index: 2;
    min-height: 36px;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #24405f;
    text-decoration: none;
    background: #eef4ff;
    border: 1px solid rgba(31, 64, 109, 0.2);
}

main {
    padding: 18px;
    animation: page-rise 0.45s ease-out both;
}

.auth-required-banner {
    margin-bottom: 10px;
    padding: 10px 12px;
    border: 1px solid rgba(190, 46, 46, 0.18);
    border-radius: 10px;
    background: #fff5f5;
    color: #9f2f2f;
    font-weight: 700;
    font-size: 0.9rem;
}

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

.strategy-tabs-section {
    margin-bottom: 12px;
}

.strategy-tabs-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.strategy-tabs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Right side: filter controls (pool/score) + meta badges. */
.strategy-tabs-right {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    flex-wrap: wrap;
    width: 100%;
}

.strategy-tabs-filters {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    flex: 1 1 auto;
}

/* Compact inline layout for pool/score inside the tab bar. */
.strategy-tabs-filters .filter-group {
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.strategy-tabs-filters .filter-group label {
    margin-bottom: 0;
    white-space: nowrap;
    font-weight: 800;
}

.strategy-tabs-filters #strategy-fixed-group > label,
.strategy-tabs-filters #pool-filter-group > label,
.strategy-tabs-filters #score-filter-group > label {
    display: none;
}

.strategy-tabs-filters select,
.strategy-tabs-filters input,
.strategy-tabs-filters .score-input-group input {
    min-height: 40px;
    padding: 8px 10px;
}

.strategy-tabs-filters #pool-select {
    width: 230px;
}

.strategy-tabs-filters #strategy-fixed-group,
.strategy-tabs-filters #strategy-select {
    width: 230px;
}

.strategy-tabs-filters #score-filter-group .score-input-group {
    display: block;
}

.strategy-tabs-filters #score-threshold {
    width: 140px;
}

.fundamentals-inline-group {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

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

.metric-dropdown {
    position: relative;
}

.metric-dropdown > summary {
    list-style: none;
    cursor: pointer;
    border: 1px solid rgba(25, 45, 75, 0.2);
    border-radius: 999px;
    padding: 7px 12px;
    background: rgba(255, 255, 255, 0.92);
    color: #274364;
    font-weight: 800;
}

.metric-dropdown > summary::-webkit-details-marker {
    display: none;
}

.metric-dropdown[open] > summary {
    border-color: var(--accent);
}

.metric-dropdown-panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 80;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    border: 1px solid #b8c8db;
    border-radius: 12px;
    box-shadow: 0 14px 28px rgba(25, 55, 102, 0.22);
    padding: 8px 10px;
    min-width: 150px;
}

.metric-dropdown-panel input {
    width: 52px;
    min-height: 34px;
    border: 1px solid #c9d7e8;
    border-radius: 999px;
    padding: 4px 8px;
    text-align: right;
    background: #f8fbff;
}

.metric-sep,
.metric-suffix {
    color: #5b6b80;
    font-weight: 800;
    white-space: nowrap;
}

/* Place date/count badges at the far right end of the tab row. */
.strategy-tabs-meta {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

/* Only show the relevant meta for the active panel/tab. */
main.tab-fundamentals #result-date,
main.tab-fundamentals #result-count {
    display: none;
}

main:not(.tab-fundamentals) #fundamentals-date,
main:not(.tab-fundamentals) #fundamentals-count {
    display: none;
}

.strategy-tab-btn {
    border: 1px solid rgba(41, 67, 107, 0.18);
    background: linear-gradient(180deg, #ffffff 0%, #f5f9ff 100%);
    color: #1a3155;
    padding: 10px 17px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.97rem;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    backdrop-filter: blur(8px);
}

.strategy-tab-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(25, 45, 75, 0.28);
    box-shadow: 0 12px 24px rgba(9, 18, 36, 0.18);
}

.strategy-tab-btn.active {
    color: #fff;
    border-color: rgba(181, 138, 67, 0.45);
    background:
        linear-gradient(140deg, #193f82 0%, #1d4ea4 58%, #0d7193 100%);
    box-shadow: 0 14px 28px rgba(25, 63, 130, 0.34);
}

.strategy-tab-panel {
    display: none;
}

.strategy-tab-panel.active {
    display: block;
}

.strategy-tab-panel-iframe {
    margin-top: 8px;
}

.strategy-tab-iframe {
    width: 100%;
    min-height: 1250px;
    border: 0;
    border-radius: 12px;
    background: #fff;
    display: block;
}

.strategy-tab-iframe-wrap {
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 12px 26px rgba(21, 49, 96, 0.1);
}

.strategy-tab-panel-iframe .strategy-tab-iframe-wrap {
    border-color: #c9d7e8;
}

.strategy-tab-empty {
    border: 1px dashed #acc0d9;
    border-radius: 14px;
    padding: 26px 22px;
    color: var(--ink-muted);
    line-height: 1.65;
    background: linear-gradient(180deg, #f8fbff 0%, #f0f5fc 100%);
}

.filter-section {
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(25, 45, 75, 0.14);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 18px;
    box-shadow: var(--glow-soft);
}

.filter-section h2,
.results-header h2,
.detail-header h2 {
    font-family: 'Space Grotesk', sans-serif;
    color: #0f2e57;
    letter-spacing: -0.01em;
}

.filter-section h2 {
    font-size: 1.42rem;
    margin-bottom: 18px;
}

.filter-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
    align-items: flex-end;
}

/* Place the search button higher within the filter grid (align with inputs, not the bottom). */
#apply-filter {
    align-self: flex-start;
    margin-top: 0;
}

.apply-filter-top {
    margin-left: auto;
    min-height: 40px;
    padding: 0 18px;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.fundamentals-filter-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    color: #1f3553;
}

.fundamentals-filter-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.fundamentals-filter {
    /* Place it as a single horizontal row at the bottom of the filter grid. */
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: stretch;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid #d6e1f0;
    background: linear-gradient(180deg, #ffffff 0%, #f6fafe 100%);
}

.fundamentals-filter-head {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.fundamentals-filter-meta {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.fundamentals-filter-summary {
    color: #5b6b80;
    font-weight: 800;
    font-size: 0.9rem;
    white-space: nowrap;
}

.fundamentals-filter-toggle {
    appearance: none;
    border: 1px solid #c9d7e8;
    background: #ffffff;
    color: #214264;
    font-weight: 900;
    border-radius: 999px;
    padding: 7px 10px;
    cursor: pointer;
}

.fundamentals-filter-toggle:hover {
    background: rgba(20, 83, 204, 0.06);
}

.fundamentals-filter.is-collapsed .fundamentals-filter-fields {
    display: none;
}

.fundamentals-filter.is-collapsed .fundamentals-filter-toggle {
    color: #fff;
    border-color: transparent;
    background: linear-gradient(135deg, #1453cc 0%, #0e8aab 100%);
}

.fundamentals-filter-fields {
    margin-top: 0;
    padding: 0;
    border: 0;
    background: transparent;
    display: flex;
    flex-wrap: wrap;
    gap: 10px 12px;
    justify-content: flex-end;
    align-items: center;
}

.fundamentals-filter-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid #d6e1f0;
    border-radius: 999px;
    background: #ffffff;
}

.fundamentals-filter-name {
    color: #425e80;
    font-weight: 900;
    font-size: 0.92rem;
    white-space: nowrap;
}

.fundamentals-filter-sep,
.fundamentals-filter-suffix {
    color: #5b6b80;
    font-weight: 900;
    white-space: nowrap;
}

.fundamentals-filter-fields input[type="number"] {
    border: 1px solid #c9d7e8;
    border-radius: 999px;
    padding: 4px 6px;
    font-weight: 900;
    color: #0f1f36;
    background: #f8fbff;
    width: 46px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* PER is a free-text field: keep the same shape but use regular weight. */
#fundamentals-per-min,
#fundamentals-per-max {
    border: 1px solid #c9d7e8;
    border-radius: 999px;
    padding: 4px 6px;
    font-weight: 500;
    color: #0f1f36;
    background: #f8fbff;
    width: 46px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* PBR/DIV are also free-text fields: use regular weight (not bold). */
#fundamentals-pbr-min,
#fundamentals-pbr-max,
#fundamentals-div-min {
    border: 1px solid #c9d7e8;
    border-radius: 999px;
    padding: 4px 6px;
    font-weight: 500;
    color: #0f1f36;
    background: #f8fbff;
    width: 46px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.fundamentals-filter-fields input[type="number"]:disabled {
    opacity: 0.6;
}

@media (max-width: 980px) {
    .fundamentals-filter {
        align-items: flex-start;
        flex-direction: column;
    }
    .fundamentals-filter-fields {
        justify-content: flex-start;
    }
}

.candle-only {
    display: none;
}

main.tab-candle .candle-only {
    display: flex;
}

main.tab-candle .core-only {
    display: none;
}

main.tab-candle #score-filter-group {
    display: none;
}

main.tab-candle .filter-controls {
    grid-template-columns: 1fr 160px;
}

main.tab-candle .fundamentals-filter {
    grid-column: auto;
    padding: 10px 12px;
}

main.tab-candle .fundamentals-filter-fields input[type="number"] {
    width: 41px;
    padding: 4px 6px;
}

main.tab-compact #strategy-fixed-group {
    display: none;
}

main.tab-compact .filter-controls {
    grid-template-columns: 1fr 160px;
}

main.tab-compact #score-filter-group .score-input-group input {
    min-height: 38px;
    padding: 8px 10px;
    font-size: 0.95rem;
}

main.tab-compact #score-filter-group label {
    font-size: 0.9rem;
    margin-bottom: 6px;
}

main.tab-compact #pool-filter-group select {
    min-height: 42px;
}

/* In the tab bar, keep pool/score labels inline even in compact mode. */
main.tab-compact .strategy-tabs-filters #score-filter-group label,
main.tab-compact .strategy-tabs-filters #pool-filter-group label {
    margin-bottom: 0;
}

main.tab-compact .fundamentals-filter {
    grid-column: auto;
    padding: 10px 12px;
}

main.tab-compact .fundamentals-filter-fields input[type="number"] {
    width: 41px;
    padding: 4px 6px;
}

@media (max-width: 1000px) {
    main.tab-compact .filter-controls {
        grid-template-columns: 1fr;
    }
}

.filter-group label {
    color: #274364;
    font-size: 0.93rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.filter-group input:not([type="radio"]):not([type="checkbox"]),
.filter-group select,
.score-input-group input,
.strategy-readonly {
    width: 100%;
    min-height: 46px;
    border: 1px solid rgba(41, 67, 107, 0.22);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 1rem;
    color: var(--ink);
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.filter-group input:not([type="radio"]):not([type="checkbox"]):focus,
.filter-group select:focus,
.score-input-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(29, 78, 216, 0.16);
}

.score-input-group {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 10px;
}

.score-input-group span {
    color: var(--ink-muted);
    font-weight: 600;
}

.strategy-dropdown {
    position: relative;
    width: 100%;
}

.strategy-readonly {
    background: linear-gradient(180deg, #f8fbff 0%, #eef3fb 100%);
    color: #244268;
    font-weight: 700;
    display: flex;
    align-items: center;
}

.strategy-checkbox-store {
    display: none;
}

.strategy-dropdown-toggle {
    width: 100%;
    text-align: left;
    min-height: 40px;
    border: 1px solid #b8c8db;
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
}

.strategy-dropdown-toggle::after {
    content: '▾';
    float: right;
    color: var(--accent);
}

.strategy-dropdown-toggle:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(30, 79, 216, 0.12);
}

.strategy-dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 50;
    display: none;
    background: #fff;
    border-radius: 12px;
    border: 1px solid #b8c8db;
    box-shadow: 0 14px 28px rgba(25, 55, 102, 0.22);
    padding: 4px 0;
    max-height: min(52vh, 320px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.strategy-dropdown.open .strategy-dropdown-menu {
    display: block;
}

.strategy-check {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    color: #284464;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.2;
    cursor: pointer;
    user-select: none;
}

.strategy-check span {
    line-height: 1.2;
}

.strategy-check:hover {
    background: #eef5ff;
}

.strategy-check input {
    margin: 0;
    width: 14px;
    height: 14px;
    accent-color: var(--accent);
}

.btn-primary {
    border: none;
    min-height: 46px;
    padding: 0 24px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    color: #f8fbff;
    cursor: pointer;
    background:
        linear-gradient(135deg, #1a4288 0%, #1e4ea8 54%, #0f7d9c 100%);
    box-shadow: 0 12px 24px rgba(16, 47, 96, 0.30);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 15px 28px rgba(16, 47, 96, 0.36);
}

.btn-primary:active {
    transform: translateY(0);
}

.results-section {
    margin-bottom: 28px;
}

.ad-slot-inline {
    margin-top: 12px;
    border: 1px dashed rgba(30, 78, 168, 0.35);
    border-radius: 10px;
    min-height: 72px;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4e6690;
    background: #f4f8ff;
    font-weight: 700;
    font-size: 0.88rem;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(25, 45, 75, 0.12);
}

.fundamentals-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.fundamentals-date {
    color: #274c73;
    font-weight: 800;
    font-size: 0.92rem;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, #f8fbff 0%, #ecf2fa 100%);
    white-space: nowrap;
}

.fundamentals-market-toggle {
    display: inline-flex;
    border: 1px solid var(--line);
    border-radius: 999px;
    overflow: hidden;
    background: linear-gradient(180deg, #f8fbff 0%, #ecf2fa 100%);
}

.market-toggle-btn {
    appearance: none;
    border: 0;
    background: transparent;
    color: #1f3553;
    padding: 8px 12px;
    font-weight: 800;
    font-size: 0.92rem;
    cursor: pointer;
    border-right: 1px solid rgba(207, 218, 232, 0.9);
    transition: background-color 0.15s ease, color 0.15s ease;
}

.market-toggle-btn:last-child {
    border-right: 0;
}

.market-toggle-btn:hover {
    background: rgba(20, 83, 204, 0.08);
}

.market-toggle-btn.active {
    color: #fff;
    background: linear-gradient(135deg, #1453cc 0%, #0e8aab 100%);
}

.results-header h2 {
    font-size: 1.9rem;
    color: #1a3460;
    margin: 0;
}

.results-header h2:empty {
    display: none;
}

.result-date {
    color: #1a3a61;
    font-weight: 800;
    font-size: 0.92rem;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid rgba(41, 67, 107, 0.16);
    background: linear-gradient(180deg, #ffffff 0%, #f6faff 100%);
    white-space: nowrap;
}

.result-count {
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 0.92rem;
    font-weight: 700;
    color: #fff;
    border: 1px solid rgba(181, 138, 67, 0.45);
    background: linear-gradient(130deg, #193f82 0%, #1e4ea8 55%, #0f7d9c 100%);
}

.stocks-grid {
    display: grid;
    grid-template-columns: repeat(7, max-content);
    border: 1px solid rgba(41, 67, 107, 0.18);
    border-radius: 14px;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 70vh;
    background: rgba(255, 255, 255, 0.97);
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.86),
        0 10px 24px rgba(20, 47, 93, 0.10);
}

.fundamentals-grid {
    grid-template-columns: repeat(17, max-content);
}

.fundamentals-grid .grid-header .grid-cell.sortable {
    cursor: pointer;
    user-select: none;
}

.stocks-grid .grid-header .grid-cell.sortable,
.fundamentals-grid .grid-header .grid-cell.sortable {
    cursor: pointer;
    user-select: none;
}

.stocks-grid .grid-header .grid-cell.sortable::after,
.fundamentals-grid .grid-header .grid-cell.sortable::after {
    content: '⇅';
    display: inline-block;
    margin-left: 8px;
    font-size: 0.85em;
    color: rgba(33, 66, 100, 0.55);
}

.stocks-grid .grid-header .grid-cell.sortable.sorted-asc::after,
.fundamentals-grid .grid-header .grid-cell.sortable.sorted-asc::after {
    content: '▲';
    color: rgba(33, 66, 100, 0.9);
}

.stocks-grid .grid-header .grid-cell.sortable.sorted-desc::after,
.fundamentals-grid .grid-header .grid-cell.sortable.sorted-desc::after {
    content: '▼';
    color: rgba(33, 66, 100, 0.9);
}

.fundamentals-grid .grid-cell.market {
    color: #425e80;
    background: #f7fafd;
    font-weight: 700;
    min-width: 90px;
}

.fundamentals-grid .grid-cell.currency-positive {
    color: var(--good);
    font-weight: 700;
}

.fundamentals-grid .grid-cell.currency-negative {
    color: var(--bad);
    font-weight: 700;
}

.fundamentals-grid .grid-cell.streak {
    font-weight: 800;
    color: #173459;
    text-align: center;
    min-width: 96px;
}

.fundamentals-grid .grid-cell.ticker,
.fundamentals-grid .grid-cell.name {
    cursor: pointer;
}

.fundamentals-grid .grid-cell.ticker:hover,
.fundamentals-grid .grid-cell.name:hover {
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

.grid-header,
.grid-row {
    display: contents;
}

.grid-cell {
    padding: 11px 10px;
    border-bottom: 1px solid rgba(25, 45, 75, 0.10);
    border-right: 1px solid rgba(25, 45, 75, 0.10);
    font-size: 0.94rem;
    white-space: nowrap;
    transition: background-color 0.16s ease;
    min-width: 84px;
}

.grid-header .grid-cell {
    background: linear-gradient(180deg, #f7faff 0%, #eef4fd 100%);
    color: #132f55;
    font-weight: 800;
    border-bottom: 1px solid rgba(41, 67, 107, 0.20);
    position: sticky;
    top: 0;
    z-index: 4;
    backdrop-filter: blur(10px);
}

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

.grid-cell.center {
    text-align: center;
}

.grid-row {
    cursor: pointer;
}

.grid-row:hover .grid-cell {
    background: rgba(30, 78, 168, 0.075);
}

.grid-cell.ticker {
    font-weight: 700;
    color: #173459;
    min-width: 96px;
}

.grid-cell.name {
    color: #304f73;
    min-width: 140px;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.grid-cell.pool {
    color: #425e80;
    background: #f7fafd;
    font-weight: 600;
    min-width: 90px;
}

.score-positive {
    color: var(--good);
    font-weight: 700;
}

.score-negative {
    color: var(--bad);
    font-weight: 700;
}

.score-neutral {
    color: #7a899d;
    font-weight: 600;
}

.loading,
.empty-message {
    text-align: center;
    padding: 60px 20px;
    color: #647791;
    font-size: 1.05rem;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 24px;
    height: 24px;
    margin-left: 10px;
    border-radius: 50%;
    border: 3px solid #cad7ea;
    border-top-color: #1560d4;
    vertical-align: middle;
    animation: spin 0.8s linear infinite;
}

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

.detail-section {
    margin-top: 26px;
    background: rgba(255, 255, 255, 0.84);
    border: 1px solid rgba(25, 45, 75, 0.14);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--glow-soft);
}

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

.detail-header h2 {
    font-size: 1.38rem;
}

.btn-close {
    width: 36px;
    height: 36px;
    border: 1px solid #b9c8db;
    border-radius: 50%;
    background: #fff;
    color: #426387;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

.btn-close:hover {
    background: #edf4ff;
    color: #1f4f8a;
}

.detail-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px;
}

.detail-info {
    display: grid;
    gap: 12px;
}

.info-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 13px 14px;
    border-radius: 11px;
    border: 1px solid #c8d8ea;
    background: #fff;
}

.info-item .label {
    color: #4a6483;
    font-size: 0.95rem;
    font-weight: 600;
}

.info-item .value {
    color: #19395f;
    font-size: 1.04rem;
    font-weight: 700;
}

.btn-naver {
    width: 100%;
    max-width: 300px;
    border: none;
    border-radius: 12px;
    min-height: 44px;
    padding: 10px 20px;
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    background: linear-gradient(135deg, #08a968 0%, #0f8e5a 100%);
    box-shadow: 0 10px 18px rgba(8, 169, 104, 0.24);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.btn-naver:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 22px rgba(8, 169, 104, 0.31);
}

footer {
    border-top: 1px solid rgba(40, 84, 138, 0.16);
    background: rgba(248, 252, 255, 0.86);
    color: rgba(15, 23, 42, 0.66);
    text-align: center;
    padding: 12px 14px;
    font-size: 0.93rem;
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}

.visit-counts {
    margin-top: 6px;
    display: flex;
    justify-content: center;
    gap: 18px;
    flex-wrap: wrap;
}

@media (max-width: 1000px) {
    .strategy-tab-iframe {
        min-height: 980px;
    }

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

    .filter-controls {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    body {
        padding: 0;
    }

    .container {
        border-radius: 0;
        min-height: 100vh;
    }

    .site-header {
        padding: 14px 12px;
    }

    .header-cta {
        top: 10px;
        right: 8px;
        min-height: 32px;
        padding: 6px 10px;
        font-size: 0.78rem;
    }

    .header-donate-cta {
        top: 10px;
        right: 104px;
        min-height: 32px;
        padding: 6px 9px;
        font-size: 0.75rem;
    }

    main {
        padding: 12px;
    }

    .strategy-tabs {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .strategy-tabs-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .strategy-tabs-meta {
        justify-content: flex-end;
    }

    .strategy-tab-btn {
        width: 100%;
        text-align: center;
        padding: 9px 10px;
        font-size: 0.92rem;
    }

    .filter-section {
        padding: 16px;
    }

    .filter-controls {
        gap: 13px;
    }

    .score-input-group {
        grid-template-columns: 1fr;
        align-items: stretch;
        gap: 7px;
    }

    .btn-primary,
    .btn-naver {
        width: 100%;
        max-width: none;
    }

    #apply-filter {
        margin-top: 0;
    }

    .stocks-grid {
        grid-template-columns: repeat(7, max-content);
    }

    .grid-cell {
        padding: 10px 7px;
        font-size: 0.9rem;
    }

    .detail-section {
        padding: 16px;
    }

    .info-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .auth-chip-wrap {
        top: 10px;
        left: 8px;
        max-width: calc(100vw - 160px);
    }

    .auth-user-email {
        max-width: 94px;
    }

    .auth-chip-btn {
        min-height: 26px;
        padding: 0 8px;
        font-size: 0.7rem;
    }
}
