/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0b0e14;
    --bg-secondary: #131820;
    --bg-card: #1a202c;
    --bg-card-hover: #1f2735;
    --border-color: #2a3440;
    --text-primary: #e8edf5;
    --text-secondary: #8892a6;
    --text-muted: #5a6478;
    --accent-blue: #4f7cff;
    --accent-blue-dim: rgba(79, 124, 255, 0.15);
    --red-up: #ef4444;
    --red-up-bg: rgba(239, 68, 68, 0.12);
    --green-down: #22c55e;
    --green-down-bg: rgba(34, 197, 94, 0.12);
    --premium-high: #f59e0b;
    --premium-high-bg: rgba(245, 158, 11, 0.12);
    --discount-bg: rgba(34, 197, 94, 0.08);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --radius: 10px;
    --radius-sm: 6px;
}

html {
    font-size: 14px;
}

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

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #3a4450; }

/* ===== Header ===== */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    background: linear-gradient(135deg, #e8edf5, #8892a6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

.update-time {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}

.refresh-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.refresh-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--accent-blue);
}

.refresh-btn:active {
    transform: scale(0.96);
}

/* ===== Main ===== */
.main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 24px 40px;
}

/* ===== Section ===== */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}

.section-header h2 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
}

.auto-refresh-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green-down);
    animation: pulse-dot 2s ease-in-out infinite;
}

.dot.paused {
    background: var(--text-muted);
    animation: none;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ===== Loading ===== */
.loading .card-loader {
    height: 100%;
    min-height: 100px;
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===== ETF Cards ===== */
.etf-section {
    margin-bottom: 28px;
}

.etf-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.etf-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.etf-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent-blue);
    opacity: 0.6;
}

.etf-card:hover {
    border-color: var(--accent-blue);
    box-shadow: 0 4px 20px rgba(79, 124, 255, 0.08);
    transform: translateY(-1px);
}

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

.card-name {
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-name h3 {
    font-size: 1rem;
    font-weight: 600;
}

.card-name .code {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 2px 8px;
    border-radius: 4px;
}

.card-name .exchange-tag {
    font-size: 0.65rem;
    color: var(--accent-blue);
    background: var(--accent-blue-dim);
    padding: 1px 6px;
    border-radius: 3px;
    font-weight: 500;
}

.card-price-area {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 12px;
}

.card-price {
    font-size: 2rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.card-change {
    font-size: 0.9rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.card-change.up { color: var(--red-up); }
.card-change.down { color: var(--green-down); }

.card-details {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.detail-item .label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.detail-item .value {
    font-size: 0.85rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.etf-card.loading .card-loader {
    min-height: 130px;
}

/* ===== ETF Tabs ===== */
.etf-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 16px;
}

.tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.25s;
}

.tab:hover {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.03);
}

.tab.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.tab .tab-name { font-weight: 500; }
.tab .tab-code { font-size: 0.75rem; opacity: 0.6; }

/* ===== Expiry Selector ===== */
.expiry-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.expiry-selector label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.expiry-selector select {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.expiry-selector select:hover,
.expiry-selector select:focus {
    border-color: var(--accent-blue);
}

/* ===== Options Table ===== */
.options-section {
    margin-bottom: 28px;
}

.options-table-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

.table-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
    gap: 16px;
}

.loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.options-table {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}

.options-table th {
    background: var(--bg-secondary);
    padding: 10px 12px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 2;
}

.options-table td {
    padding: 9px 12px;
    font-size: 0.85rem;
    border-bottom: 1px solid rgba(42, 52, 64, 0.4);
    white-space: nowrap;
    text-align: center;
}

.options-table tr:hover td {
    background: rgba(79, 124, 255, 0.04);
}

.options-table .col-strike {
    font-weight: 600;
    color: var(--text-primary);
    background: rgba(42, 52, 64, 0.2);
    font-size: 0.9rem;
}

.options-table .col-call-strike {
    border-right: 2px solid rgba(239, 68, 68, 0.2);
}

.options-table .col-put-strike {
    border-left: 2px solid rgba(34, 197, 94, 0.2);
}

.options-table .col-call { color: var(--red-up); }
.options-table .col-put { color: var(--green-down); }

.options-table .up { color: var(--red-up); }
.options-table .down { color: var(--green-down); }

.options-table .premium-high {
    color: var(--premium-high);
}

.options-table .premium-normal {
    color: var(--text-secondary);
}

.options-table .premium-discount {
    color: var(--green-down);
}

/* ===== Premium Panels ===== */
.premium-section {
    margin-bottom: 28px;
}

.premium-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.premium-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
}

.premium-panel h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.premium-panel h3 .badge {
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}

.badge-call { background: rgba(239, 68, 68, 0.15); color: var(--red-up); }
.badge-put { background: rgba(34, 197, 94, 0.15); color: var(--green-down); }

.premium-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.premium-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.premium-item:hover {
    background: var(--bg-card-hover);
}

.premium-item .strike-label {
    font-weight: 600;
    min-width: 70px;
    font-size: 0.85rem;
}

.premium-item .premium-bar-wrap {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.premium-item .premium-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
    position: relative;
}

.premium-item .premium-bar.positive {
    background: linear-gradient(90deg, var(--premium-high), #f97316);
}

.premium-item .premium-bar.negative {
    background: linear-gradient(90deg, var(--green-down), #10b981);
}

.premium-item .premium-value {
    min-width: 70px;
    text-align: right;
    font-weight: 500;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}

.premium-item .premium-value.positive { color: var(--premium-high); }
.premium-item .premium-value.negative { color: var(--green-down); }

.premium-summary {
    margin-top: 14px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.premium-summary strong {
    color: var(--text-secondary);
    font-weight: 500;
}

/* ===== Table Empty State ===== */
.table-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.table-empty svg {
    margin-bottom: 12px;
    opacity: 0.4;
}

.table-empty p {
    font-size: 0.9rem;
}

/* ===== Footer ===== */
.footer {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.footer p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ===== Scrollable Table Container ===== */
.table-scroll {
    overflow-x: auto;
    max-height: 600px;
    overflow-y: auto;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .etf-cards {
        grid-template-columns: repeat(2, 1fr);
    }
    .premium-panels {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .etf-cards {
        grid-template-columns: 1fr;
    }
    .header-inner {
        padding: 12px 16px;
        flex-direction: column;
        gap: 10px;
    }
    .main {
        padding: 16px;
    }
    .tab .tab-code { display: none; }
    .card-details {
        grid-template-columns: repeat(2, 1fr);
    }
    .footer {
        flex-direction: column;
        text-align: center;
    }
    .options-table th,
    .options-table td {
        padding: 7px 8px;
        font-size: 0.78rem;
    }
}