/* ===== CSS Variables & Reset ===== */
:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d2e;
    --bg-card: #1e2235;
    --bg-card-hover: #252a40;
    --text-primary: #e8eaed;
    --text-secondary: #9aa0b0;
    --text-muted: #6b7280;
    --accent-blue: #4f8ff7;
    --accent-green: #00d4aa;
    --accent-red: #ff5252;
    --accent-yellow: #ffc107;
    --accent-orange: #ff9800;
    --border-color: #2a2f45;
    --gradient-buy: linear-gradient(135deg, #00d4aa, #00b894);
    --gradient-sell: linear-gradient(135deg, #ff5252, #ff1744);
    --gradient-hold: linear-gradient(135deg, #ffc107, #ff9800);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.3);
    --shadow-card: 0 4px 16px rgba(0,0,0,0.2);
    --radius: 12px;
    --radius-sm: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===== Header ===== */
header {
    background: linear-gradient(135deg, #1a1d2e 0%, #0f1117 100%);
    border-bottom: 1px solid var(--border-color);
    padding: 24px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.header-content h1 {
    font-size: 28px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.version {
    font-size: 0.45em;
    font-weight: 400;
    color: var(--text-muted);
    vertical-align: middle;
    margin-left: 4px;
}

.btn-refresh {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 18px;
    font-size: .85rem;
    font-weight: 600;
    color: var(--accent-blue);
    background: rgba(79, 143, 247, 0.12);
    border: 1px solid rgba(79, 143, 247, 0.3);
    border-radius: 20px;
    cursor: pointer;
    transition: background .2s, transform .15s;
    box-shadow: 0 2px 6px rgba(0,0,0,.2);
    white-space: nowrap;
}
.btn-refresh:hover {
    background: rgba(79, 143, 247, 0.22);
}
.btn-refresh:active {
    transform: scale(.95);
}
.btn-refresh .icon {
    display: inline-block;
    transition: transform .4s;
}
.btn-refresh.loading {
    pointer-events: none;
    opacity: .7;
}
.btn-refresh.loading .icon {
    animation: spin 1s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

.logo-icon {
    font-size: 32px;
}

.subtitle {
    font-size: 16px;
    font-weight: 400;
    color: var(--text-secondary);
    margin-left: 4px;
}

.header-desc {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 4px;
}

/* ===== Hero / Main Index ===== */
.hero-section {
    display: flex;
    justify-content: center;
    padding: 40px 0 20px;
}

.main-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 32px 48px;
    text-align: center;
    min-width: 400px;
    box-shadow: var(--shadow-lg);
    transition: transform 0.3s ease;
}

.main-card:hover {
    transform: translateY(-2px);
}

.card-label {
    font-size: 16px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 8px;
}

.index-value {
    font-size: 72px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
    margin: 8px 0;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.index-gauge {
    width: 100%;
    height: 160px;
    margin: 8px 0;
}

.signal-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 24px;
    border-radius: 24px;
    font-size: 18px;
    font-weight: 600;
    margin: 12px 0;
    background: rgba(79, 143, 247, 0.15);
    color: var(--accent-blue);
}

.signal-badge.buy {
    background: rgba(0, 212, 170, 0.15);
    color: var(--accent-green);
}

.signal-badge.sell {
    background: rgba(255, 82, 82, 0.15);
    color: var(--accent-red);
}

.signal-badge.hold {
    background: rgba(255, 193, 7, 0.15);
    color: var(--accent-yellow);
}

.update-time {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* ===== Section Titles ===== */
.section-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 20px;
    padding-left: 12px;
    border-left: 4px solid var(--accent-blue);
}

/* ===== Indicators Section ===== */
.indicators-section {
    padding: 20px 0;
}

.indicators-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.indicator-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-card);
}

.indicator-card:hover {
    background: var(--bg-card-hover);
    transform: translateY(-2px);
}

.indicator-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.indicator-icon {
    font-size: 24px;
}

.indicator-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.indicator-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--accent-blue);
    margin-bottom: 12px;
    font-variant-numeric: tabular-nums;
}

.indicator-percentile {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.percentile-value {
    font-weight: 700;
    color: var(--text-primary);
}

.percentile-bar {
    width: 100%;
    height: 8px;
    background: rgba(255,255,255,0.08);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.percentile-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 1s ease;
    width: 0%;
    background: var(--accent-blue);
}

.indicator-formula {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

/* ===== Indicator 3-day rows ===== */
.indicator-days {
    margin-bottom: 12px;
}

.day-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.day-row:last-child {
    border-bottom: none;
}

.day-date {
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 42px;
    flex-shrink: 0;
}

.day-value {
    font-size: 15px;
    font-weight: 700;
    color: var(--accent-blue);
    min-width: 72px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

.day-pct-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.day-pct {
    font-size: 13px;
    font-weight: 700;
    min-width: 32px;
    text-align: right;
    flex-shrink: 0;
}

.day-pct-wrap .percentile-bar {
    flex: 1;
    margin-bottom: 0;
}

/* ===== Recent days in hero card ===== */
.recent-days {
    margin-top: 16px;
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
}

.recent-days-title {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-align: left;
}

.recent-days-table {
    width: 100%;
    font-size: 14px;
    border-collapse: collapse;
}

.recent-days-table th {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    padding: 4px 8px;
    border-bottom: 1px solid var(--border-color);
    background: transparent;
    position: static;
}

.recent-days-table td {
    padding: 6px 8px;
    white-space: nowrap;
}

.recent-days-table tr {
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.recent-days-table tr:last-child {
    border-bottom: none;
}

/* ===== Charts ===== */
.chart-section {
    padding: 20px 0;
}

.chart-container {
    width: 100%;
    height: 450px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow-card);
}

/* ===== Table ===== */
.table-section {
    padding: 20px 0;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.table-header .section-title {
    margin-bottom: 0;
}

.export-btn {
    background: var(--accent-blue);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.export-btn:hover {
    background: #3a7ae0;
    transform: translateY(-1px);
}

.table-wrapper {
    overflow-x: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th, td {
    padding: 12px 16px;
    text-align: right;
    white-space: nowrap;
}

th:first-child, td:first-child {
    text-align: left;
}

th {
    background: rgba(79, 143, 247, 0.08);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 13px;
    border-bottom: 2px solid var(--border-color);
    position: sticky;
    top: 0;
}

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

th.sortable:hover {
    color: var(--accent-blue);
}

tr {
    border-bottom: 1px solid rgba(255,255,255,0.04);
    transition: background 0.2s;
}

tr:hover {
    background: rgba(79, 143, 247, 0.05);
}

td {
    font-variant-numeric: tabular-nums;
}

.signal-cell {
    font-weight: 600;
}

.signal-cell.buy { color: var(--accent-green); }
.signal-cell.sell { color: var(--accent-red); }
.signal-cell.hold { color: var(--accent-yellow); }

/* ===== Strategy ===== */
.strategy-section {
    padding: 20px 0 40px;
}

.strategy-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.strategy-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    box-shadow: var(--shadow-card);
}

.strategy-card h3 {
    font-size: 18px;
    margin: 12px 0 8px;
}

.strategy-card p {
    font-size: 15px;
    color: var(--text-secondary);
}

.strategy-card.buy { border-top: 3px solid var(--accent-green); }
.strategy-card.hold { border-top: 3px solid var(--accent-yellow); }
.strategy-card.sell { border-top: 3px solid var(--accent-red); }

.strategy-icon {
    font-size: 36px;
}

.strategy-desc {
    font-size: 13px !important;
    color: var(--text-muted) !important;
    margin-top: 8px;
}

/* ===== Footer ===== */
footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 24px 0;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

.footer-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .indicators-grid,
    .strategy-grid {
        grid-template-columns: 1fr;
    }

    .main-card {
        min-width: auto;
        padding: 24px;
    }

    .index-value {
        font-size: 52px;
    }

    .chart-container {
        height: 350px;
    }

    .header-content h1 {
        font-size: 22px;
    }

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

/* ===== Warnings (below refresh button) ===== */
.header-warnings {
    margin-top: 8px;
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
}
.warning-item {
    color: var(--accent-yellow);
    font-size: 13px;
    padding: 2px 0;
}
