/* ============================================================
   Tokens
   ============================================================ */
:root {
    --at-ink: #171717;
    --at-paper: #fafaf8;
    --at-sand: #f5f1e8;
    --at-clay: #b38b6d;
    --at-accent: #c9a227;
    --at-smoke: #808080;
    --at-iron: #4a4a4a;
    --at-border: rgba(23,23,23,0.06);
    --at-up: #c44;
    --at-down: #5a8a6a;
    --at-font-display: 'Outfit', sans-serif;
    --at-font-mono: 'JetBrains Mono', monospace;
    --at-ease: cubic-bezier(0.16, 1, 0.3, 1);
}

.dark {
    --at-ink: #e8e8e8;
    --at-paper: #1a1a1a;
    --at-sand: #252525;
    --at-clay: #c9a574;
    --at-accent: #d4b02e;
    --at-smoke: #999;
    --at-iron: #b0b0b0;
    --at-border: rgba(255,255,255,0.08);
    --at-up: #e05555;
    --at-down: #6aab7e;
}

/* ============================================================
   Container
   ============================================================ */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 40px;
}

/* ============================================================
   Animations
   ============================================================ */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.7s var(--at-ease), transform 0.7s var(--at-ease);
}
.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}
.reveal.stagger-1 { transition-delay: 0.05s; }
.reveal.stagger-2 { transition-delay: 0.12s; }
.reveal.stagger-3 { transition-delay: 0.20s; }
.reveal.stagger-4 { transition-delay: 0.28s; }
.reveal.stagger-5 { transition-delay: 0.36s; }
.reveal.stagger-6 { transition-delay: 0.44s; }

/* ============================================================
   Background Glows
   ============================================================ */
.bg-glow {
    position: fixed;
    width: 500px; height: 500px;
    border-radius: 50%;
    filter: blur(160px);
    opacity: 0.05;
    pointer-events: none;
    z-index: 0;
}
.bg-glow-1 { top: -200px; right: -100px; background: var(--at-accent); }
.bg-glow-2 { bottom: -200px; left: -100px; background: var(--at-clay); }

/* ============================================================
   Header
   ============================================================ */
.page-header {
    position: relative;
    z-index: 1;
    padding: 64px 0 32px;
}
.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}
.page-title {
    font-family: var(--at-font-display);
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--at-ink);
}
.page-subtitle {
    font-size: 0.9rem;
    color: var(--at-smoke);
    margin-top: 4px;
}
.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}
.refresh-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--at-border);
    color: var(--at-iron);
    font-family: var(--at-font-display);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s var(--at-ease);
}
.refresh-btn:hover {
    border-color: var(--at-clay);
    color: var(--at-clay);
}
.refresh-btn.loading {
    opacity: 0.6;
    pointer-events: none;
}
.refresh-btn.loading .refresh-icon {
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.update-time {
    font-family: var(--at-font-mono);
    font-size: 0.78rem;
    color: var(--at-smoke);
}
.run-days {
    font-family: var(--at-font-mono);
    font-size: 0.78rem;
    color: var(--at-clay);
}

/* ============================================================
   Section Utilities
   ============================================================ */
.section-label {
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--at-smoke);
    margin-bottom: 16px;
}
.t1-badge {
    display: inline-block;
    font-size: 0.78em;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    color: var(--at-accent);
    border: 1px solid var(--at-accent);
    padding: 2px 8px;
    margin-left: 8px;
    vertical-align: middle;
}

/* ============================================================
   Overview Card Grid
   ============================================================ */
.overview-section {
    position: relative;
    z-index: 1;
    margin-bottom: 48px;
}
.overview-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}
.metric-card {
    background: var(--at-sand);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.metric-card__label {
    font-size: 0.85rem;
    color: var(--at-smoke);
    font-weight: 400;
}
.metric-card__value {
    font-family: var(--at-font-mono);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--at-ink);
    line-height: 1.2;
}
.metric-card__unit {
    font-family: var(--at-font-display);
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--at-smoke);
    margin-left: 4px;
}
.metric-card__value.positive { color: var(--at-up); }
.metric-card__value.negative { color: var(--at-down); }

/* ============================================================
   Performance Metrics Row
   ============================================================ */
.metrics-section {
    position: relative;
    z-index: 1;
    margin-bottom: 48px;
}
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

/* ============================================================
   AI Prediction Block
   ============================================================ */
.prediction-section {
    position: relative;
    z-index: 1;
    margin-bottom: 48px;
}
.prediction-block {
    background: var(--at-sand);
    padding: 32px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 32px;
    align-items: start;
}
.prediction-direction {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 120px;
}
.prediction-direction__icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.prediction-direction__icon svg {
    width: 36px;
    height: 36px;
}
.prediction-direction__label {
    font-family: var(--at-font-display);
    font-size: 1.65rem;
    font-weight: 700;
}
.prediction-direction__label.up { color: var(--at-up); }
.prediction-direction__label.down { color: var(--at-down); }
.prediction-direction__label.error { color: var(--at-smoke); font-size: 1.25rem; }

.prediction-details {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.prediction-meta {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}
.prediction-meta__item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.prediction-meta__item-label {
    font-size: 0.78rem;
    color: var(--at-smoke);
}
.prediction-meta__item-value {
    font-family: var(--at-font-mono);
    font-size: 1rem;
    font-weight: 500;
}
.prediction-action-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    font-size: 0.88rem;
    font-weight: 500;
}
.prediction-action-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.action-buy .prediction-action-dot { background: var(--at-up); }
.action-buy.prediction-action-badge { color: var(--at-up); }
.action-sell .prediction-action-dot { background: var(--at-down); }
.action-sell.prediction-action-badge { color: var(--at-down); }
.action-hold .prediction-action-dot { background: var(--at-smoke); }
.action-hold.prediction-action-badge { color: var(--at-smoke); }

.prediction-reasoning {
    border-top: 1px solid var(--at-border);
    padding-top: 16px;
}
.reasoning-toggle {
    font-size: 0.88rem;
    color: var(--at-clay);
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    font-family: var(--at-font-display);
    transition: color 0.3s var(--at-ease);
}
.reasoning-toggle:hover { color: var(--at-accent); }
.reasoning-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s var(--at-ease);
    font-size: 0.9rem;
    color: var(--at-iron);
    line-height: 1.7;
}
.reasoning-content.expanded {
    max-height: 500px;
    margin-top: 8px;
}
.prediction-stats {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    min-width: 100px;
}
.prediction-stats__accuracy {
    font-family: var(--at-font-display);
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--at-ink);
}
.prediction-stats__label {
    font-size: 0.78rem;
    color: var(--at-smoke);
}
.prediction-stats__detail {
    font-size: 0.78rem;
    color: var(--at-smoke);
    font-family: var(--at-font-mono);
}

/* ============================================================
   Project Info (Collapsible)
   ============================================================ */
.project-info-section {
    margin-bottom: 32px;
}
.project-info__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 16px 0;
    border-bottom: 1px solid var(--at-border);
    user-select: none;
    margin-bottom: 0;
}
.project-info__title {
    font-family: var(--at-font-display);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--at-ink);
    margin: 0;
}
.project-info__toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--at-smoke);
    display: flex;
    align-items: center;
    transition: transform 0.3s ease;
}
.project-info__toggle-btn.expanded {
    transform: rotate(180deg);
}
.project-info__content {
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.16,1,0.3,1), opacity 0.25s ease;
}
.project-info__content.collapsed {
    max-height: 0;
    opacity: 0;
}
.project-info__content.expanded {
    max-height: 1400px;
    opacity: 1;
}
.project-info__inner {
    padding-top: 24px;
}

/* ============================================================
   Disclosure Card (Risk + About)
   ============================================================ */
.disclosure-section {
    position: relative;
    z-index: 1;
    margin-bottom: 48px;
}
.disclosure-card {
    border-left: 3px solid var(--at-accent);
    background: var(--at-sand);
    padding: 32px 32px 32px 24px;
}
.disclosure-section-inner + .disclosure-section-inner {
    border-top: 1px solid var(--at-border);
    padding-top: 24px;
    margin-top: 24px;
}
.disclosure-title {
    font-family: var(--at-font-display);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--at-ink);
    margin-bottom: 8px;
}
.disclosure-text {
    font-size: 0.9rem;
    color: var(--at-iron);
    line-height: 1.8;
}
.disclosure-text strong {
    color: var(--at-ink);
    font-weight: 500;
}
.disclosure-text .accent {
    color: var(--at-accent);
    font-weight: 500;
}

/* ============================================================
   AI Trading Workflow
   ============================================================ */
.workflow-section {
    margin-top: 32px;
}
.workflow-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}
.workflow-phase {
    background: var(--at-sand);
    padding: 24px 16px;
    position: relative;
}
.workflow-phase::before {
    content: '';
    position: absolute;
    left: 0;
    top: 24px;
    bottom: 24px;
    width: 2px;
    background: var(--at-accent);
}
.workflow-phase__header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 16px;
    padding-left: 8px;
}
.workflow-phase__num {
    font-family: var(--at-font-display);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--at-accent);
    line-height: 1;
}
.workflow-phase__title {
    font-family: var(--at-font-display);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--at-ink);
}
.workflow-phase__steps {
    padding-left: 8px;
}
.workflow-step {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 0.85rem;
    color: var(--at-iron);
}
.workflow-step:last-child {
    margin-bottom: 0;
}
.workflow-step__dot {
    flex-shrink: 0;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--at-clay);
    margin-top: 6px;
}
.workflow-step__text {
    line-height: 1.5;
}
.workflow-phase--notes {
    grid-column: 1 / -1;
}
.workflow-notes {
    padding-left: 8px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px 20px;
}
.workflow-notes p {
    font-size: 0.82rem;
    line-height: 1.6;
    color: var(--at-iron);
    margin: 0;
}
.workflow-notes strong {
    color: var(--at-ink);
    font-weight: 600;
}
@media (max-width: 768px) {
    .workflow-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .workflow-phase--notes {
        grid-column: 1 / -1;
    }
    .workflow-notes {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 480px) {
    .workflow-grid {
        grid-template-columns: 1fr;
    }
    .workflow-notes {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   Tab Bar
   ============================================================ */
.tabs-section {
    position: relative;
    z-index: 1;
    margin-bottom: 64px;
}
.tab-bar {
    display: flex;
    gap: 32px;
    border-bottom: 1px solid var(--at-border);
    margin-bottom: 32px;
}
.tab-btn {
    background: none;
    border: none;
    padding: 8px 0;
    font-family: var(--at-font-display);
    font-size: 0.95rem;
    color: var(--at-smoke);
    cursor: pointer;
    position: relative;
    transition: color 0.3s var(--at-ease);
}
.tab-btn::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--at-accent);
    transform: scaleX(0);
    transition: transform 0.3s var(--at-ease);
}
.tab-btn.active {
    color: var(--at-ink);
}
.tab-btn.active::after {
    transform: scaleX(1);
}
.tab-btn:hover {
    color: var(--at-ink);
}
.tab-panel {
    display: none;
}
.tab-panel.active {
    display: block;
}

/* ============================================================
   Chart Containers
   ============================================================ */
.chart-returns-wrapper {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.chart-container {
    width: 100%;
    background: var(--at-paper);
    position: relative;
}
.chart-tooltip {
    position: absolute;
    z-index: 10;
    background: var(--at-paper);
    border: 1px solid var(--at-sand);
    padding: 8px 12px;
    font-family: var(--at-font-mono);
    font-size: 12px;
    color: var(--at-ink);
    pointer-events: none;
    white-space: nowrap;
    line-height: 1.6;
    display: none;
}
#returns-chart { height: 380px; }
#drawdown-chart { height: 140px; }
#kline-chart { height: 480px; }
#volume-chart { height: 100px; }
.chart-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 300px;
    color: var(--at-smoke);
    font-size: 0.93rem;
}

/* ============================================================
   Trade Table
   ============================================================ */
.trade-table-wrap {
    overflow-x: auto;
}
.trade-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}
.trade-table th {
    text-align: left;
    font-weight: 500;
    font-size: 0.78rem;
    color: var(--at-smoke);
    padding: 8px 16px;
    border-bottom: 1px solid var(--at-sand);
    white-space: nowrap;
}
.trade-table th.num {
    text-align: right;
}
.trade-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--at-border);
    white-space: nowrap;
}
.trade-table td.num {
    font-family: var(--at-font-mono);
    font-size: 0.85rem;
    text-align: right;
}
.trade-table td.date {
    color: var(--at-iron);
    font-family: var(--at-font-mono);
    font-size: 0.85rem;
}
.action-cell {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.action-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}
.action-dot.buy { background: var(--at-up); }
.action-dot.sell { background: var(--at-down); }
.action-dot.hold { background: var(--at-smoke); }
.action-text.buy { color: var(--at-up); }
.action-text.sell { color: var(--at-down); }
.action-text.hold { color: var(--at-smoke); }

/* ============================================================
   Pagination
   ============================================================ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 32px 0;
}
.page-btn {
    background: none;
    border: 1px solid var(--at-border);
    padding: 6px 16px;
    font-family: var(--at-font-display);
    font-size: 0.85rem;
    color: var(--at-iron);
    cursor: pointer;
    transition: all 0.3s var(--at-ease);
}
.page-btn:hover:not(:disabled) {
    border-color: var(--at-clay);
    color: var(--at-clay);
}
.page-btn:disabled {
    opacity: 0.3;
    cursor: default;
}
.page-indicator {
    font-family: var(--at-font-mono);
    font-size: 0.85rem;
    color: var(--at-smoke);
}

/* ============================================================
   Error Boundary
   ============================================================ */
.error-message {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--at-smoke);
    font-size: 0.93rem;
}

/* ============================================================
   Skeleton Loading
   ============================================================ */
.at-skeleton {
    background: linear-gradient(90deg, var(--at-sand) 25%, var(--at-paper) 50%, var(--at-sand) 75%);
    background-size: 200% 100%;
    animation: at-shimmer 1.5s infinite;
    border-radius: 4px;
}
.at-skeleton-card {
    height: 80px;
    background: var(--at-sand);
    border-radius: 0;
}
@keyframes at-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================================
   Inline Error
   ============================================================ */
.at-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px 20px;
    color: var(--at-smoke);
    font-size: 0.9rem;
}
.at-error__retry {
    padding: 6px 16px;
    border: 1px solid var(--at-border);
    background: transparent;
    color: var(--at-iron);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s var(--at-ease);
}
.at-error__retry:hover {
    border-color: var(--at-clay);
    color: var(--at-clay);
}

/* ============================================================
   Mobile / Responsive Overrides
   ============================================================ */
@media (max-width: 768px) {
    .overview-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .overview-grid {
        grid-template-columns: 1fr;
    }
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    .prediction-block {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .header-row {
        flex-direction: column;
        align-items: flex-start;
    }
    .container {
        padding: 0 20px;
    }
}
