/* ══════════════════════════════════════════════════════════════════════
   Returns Dashboard — Page-Specific Styles
   Base design tokens and shared components come from style.css
   ══════════════════════════════════════════════════════════════════════ */

/* ── Layout ──────────────────────────────────────────────────────────── */
.returns-main {
    padding: 24px 32px 64px;
}

/* ── Hero Card ────────────────────────────────────────────────────────── */
.returns-hero {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 28px 24px;
    margin-bottom: 16px;
    position: relative;
    overflow: hidden;
}

/* Subtle accent stripe at top, matching trade cards */
.returns-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    opacity: 0.6;
}

.returns-hero-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    flex-wrap: wrap;
}

.returns-hero-title h2 {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 6px;
}

.returns-hero-subtitle {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 0.01em;
    line-height: 1.7;
}

.returns-controls {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.returns-input-group label {
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 5px;
}

.returns-input-group input {
    background: var(--bg-body);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    width: 110px;
    transition: all var(--transition);
    outline: none;
}

.returns-input-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.returns-toggle-group {
    display: flex;
    background: var(--bg-elevated);
    padding: 3px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.returns-toggle-group .btn-tab {
    padding: 5px 14px;
    font-size: 0.75rem;
}

/* ── Stats Bar ────────────────────────────────────────────────────────── */
.returns-stats-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 0;
    margin-bottom: 24px;
}

.returns-stats-bar .stat-card {
    min-width: 0;
}

.stat-sub {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-top: auto;
}

/* ── Sections ─────────────────────────────────────────────────────────── */
.returns-section {
    margin-bottom: 32px;
}

.returns-section-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.returns-section-header h3 {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.section-num {
    color: var(--accent);
    font-weight: 800;
    margin-right: 8px;
    font-size: 0.85rem;
}

.section-legend {
    color: var(--text-muted);
    font-size: 0.7rem;
    font-family: monospace;
}

/* ── Panels (card-style containers for heatmap & chart) ───────────────── */
.returns-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    transition: border-color var(--transition);
}

.returns-panel:hover {
    border-color: var(--text-muted);
}

/* ── Heatmap ─────────────────────────────────────────────────────────── */
.returns-table-wrap {
    overflow-x: auto;
}

.heatmap-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 4px;
    table-layout: fixed;
}

.heatmap-table th {
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 600;
    text-align: center;
    padding-bottom: 8px;
    letter-spacing: 0.06em;
}

.heatmap-table td {
    height: 42px;
    text-align: center;
    border-radius: var(--radius-xs);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid transparent;
}

.heatmap-table td.year-label {
    background: transparent;
    color: var(--text-muted);
    text-align: left;
    font-weight: 700;
    cursor: default;
    width: 52px;
    border: none;
    font-size: 0.75rem;
}

.heatmap-table td.empty {
    background: var(--bg-elevated);
    border-color: var(--border-subtle);
    cursor: pointer;
}

.heatmap-table td.empty:hover {
    border-color: var(--text-muted);
    background: var(--bg-card-hover);
}

.heatmap-table td.filled:hover {
    transform: scale(1.08);
    z-index: 10;
    position: relative;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    filter: brightness(1.15);
    border-color: rgba(255, 255, 255, 0.4);
}

/* ── Bar Chart ────────────────────────────────────────────────────────── */
.chart-wrapper {
    position: relative;
    height: 280px;
    width: 100%;
    display: flex;
}

.y-axis {
    width: 50px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
    padding-right: 12px;
    position: relative;
}

.y-axis-label {
    position: absolute;
    right: 12px;
    color: var(--text-muted);
    font-size: 0.62rem;
    font-family: monospace;
    white-space: nowrap;
}

.y-axis-label::after {
    content: '';
    position: absolute;
    right: -12px;
    top: 50%;
    width: 6px;
    height: 1px;
    background: var(--border);
}

.bars-container {
    flex-grow: 1;
    position: relative;
    border-bottom: 1px solid var(--border);
    border-left: 1px solid var(--border);
    background: var(--bg-elevated);
    border-radius: 0 0 var(--radius-xs) 0;
    overflow: hidden;
}

.line-chart-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.chart-dot {
    transition: opacity 150ms ease;
    cursor: pointer;
}

.line-chart-svg:hover .chart-dot {
    opacity: 0.6 !important;
}

.chart-dot:hover {
    opacity: 1 !important;
}

/* ── Modals ────────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-modal);
    backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 420px;
    padding: 28px;
    box-shadow: var(--shadow-modal);
}

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

.modal-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
}

.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 14px;
}

.form-group label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}

.form-group input {
    background: var(--bg-body);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 9px 14px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-weight: 500;
    width: 100%;
    outline: none;
    transition: border-color var(--transition);
}

.form-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ── Upgrade Card ─────────────────────────────────────────────────────── */
.upgrade-overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    justify-content: center;
    align-items: center;
}

.upgrade-overlay.hidden {
    display: none;
}

.upgrade-card {
    background: var(--bg-card);
    border: 1px solid var(--green);
    border-radius: var(--radius);
    padding: 48px 32px;
    max-width: 450px;
    text-align: center;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--green-glow);
    position: relative;
    overflow: hidden;
}

.upgrade-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--green), #4ade80);
}

.upgrade-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.upgrade-card h2 {
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 12px;
}

.upgrade-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 24px;
}

.upgrade-btn {
    background: var(--green);
    color: #000;
    border: none;
    padding: 12px 28px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
    width: 100%;
}

.upgrade-btn:hover {
    background: #4ade80;
    transform: translateY(-2px);
    box-shadow: 0 4px 16px var(--green-glow);
}

/* ── Extras (dynamic line items in returns modal) ─────────────────────── */
.btn-add-extra {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1px dashed var(--border);
    color: var(--accent);
    font-family: var(--font);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    width: 100%;
    justify-content: center;
    transition: all var(--transition);
    margin-top: 4px;
}

.btn-add-extra:hover {
    background: var(--accent-glow);
    border-color: var(--accent);
}

.extra-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
    animation: fadeIn 150ms ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.extra-row .extra-label {
    flex: 1;
    background: var(--bg-body);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 500;
    outline: none;
    transition: border-color var(--transition);
}

.extra-row .extra-amount {
    width: 120px;
    background: var(--bg-body);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 500;
    outline: none;
    transition: border-color var(--transition);
}

.extra-row .extra-label:focus,
.extra-row .extra-amount:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-remove-extra {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: var(--radius-xs);
    transition: all var(--transition);
    line-height: 1;
}

.btn-remove-extra:hover {
    color: var(--red);
    background: rgba(255, 51, 102, 0.1);
}

/* ── Mobile ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {

    html,
    body {
        overflow-x: hidden;
    }

    .returns-main {
        padding: 12px 16px 48px;
        max-width: 100vw;
        overflow-x: hidden;
    }

    .returns-hero {
        padding: 14px;
        margin-bottom: 12px;
    }

    .returns-hero-top {
        flex-direction: column;
        gap: 12px;
    }

    .returns-hero-title h2 {
        font-size: 1.05rem;
    }

    /* Stack subtitle stats vertically, hide dot separators */
    .returns-hero-subtitle {
        font-size: 0.68rem;
        line-height: 1.6;
        display: flex;
        flex-direction: column;
        gap: 1px;
    }

    .returns-hero-subtitle .sep {
        display: none;
    }

    .returns-controls {
        width: 100%;
        gap: 8px;
        flex-wrap: wrap;
    }

    .returns-input-group {
        flex: 1;
        min-width: 80px;
    }

    .returns-input-group input {
        width: 100%;
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .returns-toggle-group {
        flex-shrink: 0;
    }

    .returns-toggle-group .btn-tab {
        padding: 6px 10px;
        font-size: 0.7rem;
    }

    /* Stats: single column to prevent right-side cutoff */
    .returns-stats-bar {
        display: grid;
        grid-template-columns: 1fr;
        gap: 6px;
        margin-bottom: 16px;
    }

    .returns-stats-bar .stat-card {
        min-width: unset;
        padding: 10px 12px;
        overflow: hidden;
    }

    .returns-stats-bar .stat-value {
        font-size: 1.1rem;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .returns-section {
        margin-bottom: 20px;
    }

    .returns-section-header {
        flex-direction: column;
        gap: 4px;
        align-items: flex-start;
        margin-bottom: 8px;
        padding-bottom: 6px;
    }

    .returns-section-header h3 {
        font-size: 0.85rem;
    }

    .section-legend {
        font-size: 0.6rem;
    }

    .returns-panel {
        padding: 10px;
    }

    .heatmap-table {
        min-width: 700px;
    }

    .chart-wrapper {
        height: 200px;
    }

    .modal {
        margin: 16px;
        padding: 20px;
    }
}

/* ── Very small screens ──────────────────────────────────────────────── */
@media (max-width: 400px) {
    .returns-hero-subtitle {
        flex-direction: column;
        gap: 2px;
    }

    .returns-controls {
        flex-direction: column;
    }

    .returns-stats-bar {
        grid-template-columns: 1fr;
    }
}