/* Kalshi & Polymarket Profit Charter. Tokens, top nav, author credit, buttons,
   inputs, and scrollbars come from base.css; see THEME.md. */

/* ═══════════════════════════════════════════════════════
   BASE
   ═══════════════════════════════════════════════════════ */

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

html {
    font-size: 15px;
}

body {
    line-height: 1.6;
}

/* ═══════════════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════════════ */

.app {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 80px 24px 48px;
}

/* ═══════════════════════════════════════════════════════
   UPLOAD HERO
   ═══════════════════════════════════════════════════════ */

.upload-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 80px 24px 40px;
    position: relative;
}

.hero-glow {
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    width: 500px;
    max-width: 100%;
    height: 500px;
    background: radial-gradient(circle, rgba(187, 134, 252, 0.08) 0%, transparent 70%);
    pointer-events: none;
}

.hero-title {
    font-size: 3.2rem;
    font-weight: 700;
    letter-spacing: -0.04em;
    line-height: 1.15;
    margin-bottom: 16px;
    position: relative;
}

.hero-subtitle {
    font-size: 1.05rem;
    color: var(--text-secondary);
    max-width: 520px;
    margin-bottom: 48px;
    line-height: 1.7;
}

/* Dual-source upload grid */
.source-grid {
    width: 100%;
    max-width: 880px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 8px;
}

@media (max-width: 720px) {
    .source-grid { grid-template-columns: 1fr; gap: 16px; }
}

.source-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 24px 22px;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    background: var(--bg-surface);
    text-align: left;
    overflow: hidden;
    transition: border-color var(--transition), background var(--transition), box-shadow var(--transition), transform var(--transition);
}

/* Colored accent stripe across the top of each card */
.source-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--border);
    opacity: 0.9;
    transition: background var(--transition), height var(--transition);
}

.source-card:hover {
    transform: translateY(-1px);
}

/* ── Kalshi card: green accent ── */
.source-card--kalshi {
    border-color: rgba(0, 212, 170, 0.35);
    background:
        radial-gradient(120% 80% at 0% 0%, rgba(0, 212, 170, 0.07), transparent 55%),
        var(--bg-surface);
}
.source-card--kalshi::before {
    background: linear-gradient(90deg, rgba(0, 212, 170, 0.2), var(--green) 50%, rgba(0, 212, 170, 0.2));
}
.source-card--kalshi:hover {
    border-color: rgba(0, 212, 170, 0.65);
    box-shadow: 0 0 0 1px rgba(0, 212, 170, 0.25), 0 8px 32px rgba(0, 212, 170, 0.12);
}
.source-card--kalshi:hover::before { height: 4px; }

/* ── Polymarket card: blue accent ── */
.source-card--poly {
    border-color: rgba(82, 152, 255, 0.35);
    background:
        radial-gradient(120% 80% at 100% 0%, rgba(82, 152, 255, 0.07), transparent 55%),
        var(--bg-surface);
}
.source-card--poly::before {
    background: linear-gradient(90deg, rgba(82, 152, 255, 0.2), #5298ff 50%, rgba(82, 152, 255, 0.2));
}
.source-card--poly:hover {
    border-color: rgba(82, 152, 255, 0.65);
    box-shadow: 0 0 0 1px rgba(82, 152, 255, 0.25), 0 8px 32px rgba(82, 152, 255, 0.12);
}
.source-card--poly:hover::before { height: 4px; }

.source-card-head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.source-card-link {
    margin-left: auto;
    font-size: 0.72rem;
    color: var(--text-muted);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 6px;
    border-radius: 5px;
    transition: all 120ms ease;
}

.source-card-link:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
}

.source-card-link svg {
    opacity: 0.7;
    transition: opacity 120ms ease;
}

.source-card-link:hover svg { opacity: 1; }

.source-card-title {
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.source-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.source-badge--kalshi {
    background: rgba(0, 212, 170, 0.16);
    color: var(--green);
    border: 1px solid rgba(0, 212, 170, 0.25);
}

.source-badge--poly {
    background: rgba(82, 152, 255, 0.16);
    color: #5298ff;
    border: 1px solid rgba(82, 152, 255, 0.28);
}

/* ── Hyperliquid card: amber "oil" accent ── */
.source-card--hl {
    border-color: rgba(255, 159, 67, 0.35);
    background:
        radial-gradient(120% 80% at 100% 0%, rgba(255, 159, 67, 0.08), transparent 55%),
        var(--bg-surface);
}
.source-card--hl::before {
    background: linear-gradient(90deg, rgba(255, 159, 67, 0.2), #ff9f43 50%, rgba(255, 159, 67, 0.2));
}
.source-card--hl:hover {
    border-color: rgba(255, 159, 67, 0.65);
    box-shadow: 0 0 0 1px rgba(255, 159, 67, 0.25), 0 8px 32px rgba(255, 159, 67, 0.12);
}
.source-card--hl:hover::before { height: 4px; }

.source-badge--hl {
    background: rgba(255, 159, 67, 0.16);
    color: #ff9f43;
    border: 1px solid rgba(255, 159, 67, 0.3);
}

.hl-hide-btn {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    border-radius: 6px;
    transition: color var(--transition), background var(--transition);
}
.hl-hide-btn:hover { color: var(--text-primary); background: rgba(255, 255, 255, 0.06); }

.poly-saved-pfp--hl {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ff9f43;
    background: rgba(255, 159, 67, 0.12);
}

/* Three-up source grid once Hyperliquid is unlocked */
.source-grid--with-hl {
    max-width: 1160px;
    grid-template-columns: 1fr 1fr 1fr;
}
@media (max-width: 980px) {
    .source-grid--with-hl { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
    .source-grid--with-hl { grid-template-columns: 1fr; }
}

/* ── Oil-barrel unlock toggle ── */
.hl-unlock-row {
    width: 100%;
    max-width: 880px;
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}
.hl-barrel {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 7px;
    border-radius: 999px;
    border: 1px solid rgba(255, 159, 67, 0.28);
    background: rgba(255, 159, 67, 0.05);
    color: #ff9f43;
    cursor: pointer;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    opacity: 0.85;
    transition: border-color var(--transition), background var(--transition), box-shadow var(--transition), transform var(--transition), opacity var(--transition);
}
.hl-barrel:hover { opacity: 1; }
.hl-barrel-svg {
    color: #ff9f43;
    transform-origin: 50% 90%;
    transition: filter var(--transition);
}
.hl-barrel-label { color: var(--text-secondary); }
.hl-barrel:hover {
    background: rgba(255, 159, 67, 0.12);
    border-color: rgba(255, 159, 67, 0.6);
    box-shadow: 0 0 0 1px rgba(255, 159, 67, 0.25), 0 6px 26px rgba(255, 159, 67, 0.22);
}
.hl-barrel:hover .hl-barrel-label { color: var(--text-primary); }
.hl-barrel:hover .hl-barrel-svg {
    animation: hl-barrel-wiggle 0.6s ease-in-out infinite;
    filter: drop-shadow(0 0 6px rgba(255, 159, 67, 0.9));
}
.hl-barrel-drop { transition: opacity var(--transition); }
.hl-barrel.is-active {
    border-color: rgba(255, 159, 67, 0.55);
    background: rgba(255, 159, 67, 0.14);
}
@keyframes hl-barrel-wiggle {
    0%, 100% { transform: rotate(-6deg); }
    50%      { transform: rotate(6deg); }
}
@media (prefers-reduced-motion: reduce) {
    .hl-barrel:hover .hl-barrel-svg { animation: none; }
}

.source-drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 28px 18px;
    border-radius: var(--radius-lg);
    border: 2px dashed rgba(0, 212, 170, 0.28);
    background: var(--bg-card);
    cursor: pointer;
    text-align: center;
    transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}
.source-drop:hover {
    border-color: rgba(0, 212, 170, 0.55);
    background: var(--bg-card-hover);
    box-shadow: inset 0 0 0 1px rgba(0, 212, 170, 0.08);
}
.source-drop.dragging {
    border-color: var(--green);
    background: rgba(0, 212, 170, 0.06);
    box-shadow: 0 0 24px rgba(0, 212, 170, 0.18);
}

.source-card--kalshi .upload-icon { color: var(--green); }

.upload-icon {
    color: var(--brand);
    opacity: 0.85;
}

.upload-text {
    color: var(--text-secondary);
    font-size: 0.88rem;
    margin: 0;
}

.source-card-hint {
    margin: 0;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.5;
}
.source-card-hint a {
    color: var(--brand);
    text-decoration: underline;
    text-decoration-color: rgba(187, 134, 252, 0.3);
    text-underline-offset: 2px;
}
.source-card-hint code {
    font-family: 'SF Mono', Consolas, Monaco, monospace;
    font-size: 0.74rem;
    padding: 1px 5px;
    border-radius: 3px;
    background: var(--bg-elevated);
    color: var(--text-secondary);
}
.source-card-hint.error { color: var(--red); }

.address-form {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.address-input {
    flex: 1 1 240px;
    min-width: 200px;
}

/* Blue-tinted focus/hover on the poly card's address input */
.source-card--poly .address-input {
    border-color: rgba(82, 152, 255, 0.3);
}
.source-card--poly .address-input:hover {
    border-color: rgba(82, 152, 255, 0.5);
}
.source-card--poly .address-input:focus {
    border-color: #5298ff;
    box-shadow: 0 0 0 3px rgba(82, 152, 255, 0.15);
    outline: none;
}

/* Invalid address input - overrides both the poly-card blue styling and base */
.address-input--invalid,
.source-card--poly .address-input.address-input--invalid,
.poly-inline-form .address-input.address-input--invalid {
    border-color: var(--red) !important;
    background: rgba(255, 107, 107, 0.04);
}
.address-input--invalid:focus,
.source-card--poly .address-input.address-input--invalid:focus,
.poly-inline-form .address-input.address-input--invalid:focus {
    border-color: var(--red) !important;
    box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.2) !important;
    outline: none;
}

.upload-hint {
    margin-top: 1.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}
.upload-hint a {
    color: var(--brand);
    text-decoration: underline;
    text-decoration-color: rgba(187, 134, 252, 0.3);
    text-underline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════
   CSV BAR
   ═══════════════════════════════════════════════════════ */

.csv-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.csv-list {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
}

.csv-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.csv-chip .chip-badge {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 1px 7px;
    border-radius: 999px;
}
.csv-chip .chip-badge--kalshi {
    background: rgba(0, 212, 170, 0.14);
    color: var(--green);
}
.csv-chip .chip-badge--poly {
    background: rgba(82, 152, 255, 0.14);
    color: #5298ff;
}
.csv-chip .chip-badge--hl {
    background: rgba(255, 159, 67, 0.16);
    color: #ff9f43;
}

.csv-chip .chip-addr {
    font-family: 'SF Mono', Consolas, Monaco, monospace;
    font-size: 0.74rem;
    color: var(--text-primary);
}

.csv-chip.csv-chip--loading {
    opacity: 0.7;
}
.csv-chip.csv-chip--error {
    border-color: rgba(255, 107, 107, 0.4);
    background: rgba(255, 107, 107, 0.08);
}

.csv-bar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.poly-inline-wrap {
    margin: -8px 0 24px;
}

.poly-inline-form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-brand);
    border-radius: var(--radius-md);
    flex-wrap: wrap;
}

.poly-inline-form .status {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-left: 4px;
}
.poly-inline-form .status.error { color: var(--red); }

.csv-chip .remove-csv-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 50%;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    transition: all var(--transition);
}
.csv-chip .remove-csv-btn:hover {
    background: var(--red-dim);
    color: var(--red);
}

.csv-duplicates-note {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════
   TABS
   ═══════════════════════════════════════════════════════ */

.tab-nav {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 28px;
}

.tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}
.tab-btn:hover {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.03);
}
.tab-btn.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}
.tab-btn.active svg {
    stroke: var(--brand);
}

.tab-panel {
    display: none;
    animation: fadeIn 0.3s ease;
}
.tab-panel.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════════════════
   FILTER BAR
   ═══════════════════════════════════════════════════════ */

.filter-bar {
    margin-bottom: 24px;
}

.date-filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 7px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-top: 10px;
    line-height: 1;
}

.date-filter-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
}
.date-filter-label svg {
    stroke: var(--brand-dim);
}

.date-filter-field {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.date-filter-field > span {
    color: var(--text-muted);
    font-size: 0.74rem;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.date-input {
    padding: 4px 8px;
    font-size: 0.8rem;
    line-height: 1.2;
    min-width: 0;
    width: 140px;
    color-scheme: dark;
}

.date-clear-btn {
    margin-left: auto;
    padding: 4px 10px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.74rem;
    line-height: 1.2;
    cursor: pointer;
    transition: all var(--transition);
}
.date-clear-btn:hover {
    border-color: var(--border-brand);
    color: var(--brand-bright);
}

@media (max-width: 560px) {
    .date-filter-row { gap: 8px; padding: 8px 10px; }
    .date-input { width: 100%; flex: 1; }
    .date-filter-field { flex: 1 1 100%; }
    .date-clear-btn { margin-left: 0; }
}

.filter-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-row .input {
    flex: 1;
    min-width: 200px;
}

.filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: var(--brand-glow);
    border: 1px solid var(--border-brand);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--brand-bright);
}

.filter-tag .remove-filter {
    cursor: pointer;
    color: var(--brand-dim);
    font-weight: bold;
    line-height: 1;
    transition: color var(--transition);
}
.filter-tag .remove-filter:hover {
    color: var(--red);
}

/* ═══════════════════════════════════════════════════════
   STATS GRID
   ═══════════════════════════════════════════════════════ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: all var(--transition);
}
.stat-card:hover {
    border-color: var(--border-brand);
    box-shadow: var(--shadow-glow);
}

.stat-card--accent {
    border-color: var(--border-brand);
    background: linear-gradient(135deg, rgba(187, 134, 252, 0.06) 0%, var(--bg-card) 100%);
}

.stat-label {
    font-size: 0.78rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

#profit-after-fees {
    color: var(--green);
}

.stats-row-secondary {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.stat-card-sm {
    flex: 1;
    min-width: 120px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}
.stat-card-sm:hover {
    border-color: var(--border-brand);
}

.stat-value-sm {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.stat-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.yn-split-card {
    min-width: 200px;
    flex: 1.5;
}

.yn-split-bar {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin: 6px 0 4px;
}

.yn-split-seg {
    transition: width 0.4s ease;
}

.yn-split-yes {
    border-radius: 4px 0 0 4px;
    background: #5298ff;
}

.yn-split-no {
    border-radius: 0 4px 4px 0;
    background: #a855f7;
}

.ls-split-long {
    border-radius: 4px 0 0 4px;
    background: var(--green);
}
.ls-split-short {
    border-radius: 0 4px 4px 0;
    background: var(--red);
}

.yn-split-values {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.yn-split-val {
    font-size: 1rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.yn-split-label {
    font-size: 0.7rem;
    font-weight: 600;
}

.yn-split-label.yes-label {
    color: #5298ff;
}

.yn-split-label.no-label {
    color: #a855f7;
}

/* ═══════════════════════════════════════════════════════
   TRADE DATE
   ═══════════════════════════════════════════════════════ */

.trade-date-info {
    text-align: center;
    margin-bottom: 28px;
}

#latest-trade-date {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ═══════════════════════════════════════════════════════
   PANELS
   ═══════════════════════════════════════════════════════ */

.panel {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 24px;
}

.panel-header {
    margin-bottom: 20px;
}

/* Header variant with a control on the right (e.g. ROI grouping switcher) */
.panel-header--row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

/* ROI-over-time grouping switcher */
.roi-mode-switch {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    border-radius: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
}
.roi-mode-btn {
    padding: 5px 11px;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: 7px;
    cursor: pointer;
    transition: color var(--transition), background var(--transition);
}
.roi-mode-btn:hover { color: var(--text-primary); }
.roi-mode-btn.is-active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
@media (max-width: 560px) {
    .roi-mode-switch { width: 100%; justify-content: space-between; }
}

.panel-header h2 {
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.panel-header .hint {
    margin-top: 4px;
}

/* ═══════════════════════════════════════════════════════
   CHART
   ═══════════════════════════════════════════════════════ */

.chart-plot {
    width: 100%;
    height: 450px;
}

/* ═══════════════════════════════════════════════════════
   ENTRY PRICE GRID
   ═══════════════════════════════════════════════════════ */

.entry-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-card);
}

.entry-table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

.entry-table th {
    text-align: left;
    padding: 12px 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
}

.entry-table td {
    padding: 14px 20px;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--border);
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
}

.entry-table tbody tr:last-child td {
    border-bottom: none;
}

.entry-table tbody tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.entry-range {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

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

.wr-track {
    width: 72px;
    height: 5px;
    background: var(--bg-elevated);
    border-radius: 3px;
    overflow: hidden;
    flex-shrink: 0;
}

.wr-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--brand-gradient);
    transition: width 0.5s ease;
}

.wr-cell span {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════════
   YES / NO BREAKDOWN
   ═══════════════════════════════════════════════════════ */

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

@media (max-width: 640px) {
    .yn-grid {
        grid-template-columns: 1fr;
    }
}

.yn-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: all var(--transition);
}
.yn-card:hover {
    border-color: var(--border-brand);
    box-shadow: var(--shadow-glow);
}

.yn-card--yes {
    border-top: 3px solid rgba(82, 152, 255, 0.6);
}
.yn-card--no {
    border-top: 3px solid rgba(168, 85, 247, 0.6);
}

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

.yn-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.yn-pnl {
    font-size: 1.4rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.yn-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.yn-stat {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.yn-stat-label {
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.yn-stat-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

/* ═══════════════════════════════════════════════════════
   PERFORMANCE TABLES
   ═══════════════════════════════════════════════════════ */

.perf-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 768px) {
    .perf-columns {
        grid-template-columns: 1fr;
    }
}

.perf-col {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.perf-col-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 600;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.perf-col-title--green { color: var(--green); }
.perf-col-title--red { color: var(--red); }

.perf-tables {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.perf-table-block {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.perf-table-block h5 {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 12px 16px 8px;
}

.perf-table {
    width: 100%;
    border-collapse: collapse;
}

.perf-table td {
    padding: 8px 16px;
    font-size: 0.82rem;
    border-top: 1px solid var(--border);
}

.perf-table td:last-child {
    text-align: right;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.perf-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.perf-table a {
    color: var(--text-secondary);
    transition: color var(--transition);
}
.perf-table a:hover {
    color: var(--brand-bright);
}

/* ═══════════════════════════════════════════════════════
   CALENDAR VIEW
   ═══════════════════════════════════════════════════════ */

.calendar-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.cal-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
}
.cal-nav:hover {
    border-color: var(--brand-dim);
    color: var(--brand);
    background: var(--bg-card-hover);
}

.cal-title-block {
    text-align: center;
    flex: 1;
}

.cal-title-block h2 {
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.cal-summary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 6px;
    font-size: 0.82rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}
.cal-summary strong {
    font-weight: 600;
}
.cal-sep {
    color: var(--text-muted);
    opacity: 0.4;
}

.cal-brand {
    display: block;
    font-size: 0.82rem;
    font-weight: 700;
    background: var(--brand-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.01em;
    margin-bottom: 2px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.cal-header-cell {
    text-align: center;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 8px 0;
}

.cal-cell {
    min-height: 100px;
    padding: 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    transition: all var(--transition);
    overflow: hidden;
}
.cal-cell:hover {
    border-color: var(--border-brand);
}

.cal-cell--empty {
    background: transparent;
    border-color: transparent;
}
.cal-cell--empty:hover {
    border-color: transparent;
}

/* --pnl-i (0..1) is where the day's |P&L| sits between the month's smallest and biggest day. */
.cal-cell--profit {
    background: linear-gradient(180deg, rgba(0, 255, 170, calc(0.06 + var(--pnl-i, 0) * 0.16)) 0%, rgba(0, 255, 170, calc(0.02 + var(--pnl-i, 0) * 0.10)) 100%);
    border-color: rgba(0, 255, 170, calc(0.14 + var(--pnl-i, 0) * 0.18));
}

.cal-cell--loss {
    background: linear-gradient(180deg, rgba(255, 77, 77, calc(0.06 + var(--pnl-i, 0) * 0.16)) 0%, rgba(255, 77, 77, calc(0.02 + var(--pnl-i, 0) * 0.10)) 100%);
    border-color: rgba(255, 77, 77, calc(0.14 + var(--pnl-i, 0) * 0.18));
}

.cal-day-num {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.cal-day-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.cal-day-pnl {
    font-size: 1.15rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}
.cal-day-pnl.profit { color: #00ffaa; }
.cal-day-pnl.loss { color: #ff5252; }

.cal-day-trades {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.cal-cell--today {
    box-shadow: inset 0 0 0 2px var(--brand);
}

@media (max-width: 640px) {
    .cal-cell {
        min-height: 70px;
        padding: 6px;
    }
    .cal-day-num {
        font-size: 0.75rem;
    }
    .cal-day-pnl {
        font-size: 0.82rem;
    }
    .cal-day-trades {
        display: none;
    }
}

/* ═══════════════════════════════════════════════════════
   YEARLY VIEW
   ═══════════════════════════════════════════════════════ */

.cal-nav:disabled {
    opacity: 0.35;
    cursor: default;
    pointer-events: none;
}

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

/* --pnl-i (0..1) is where the month's |P&L| sits between the year's smallest and biggest month. */
.year-cell {
    --pnl-i: 0;
    min-height: 150px;
    padding: 16px 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    /* P&L sits on the cell's vertical center; month above, stats below */
    display: grid;
    grid-template-rows: 1fr auto 1fr;
    justify-items: center;
    gap: 4px;
    font-family: var(--font);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition);
    overflow: hidden;
}
.year-cell:hover {
    border-color: var(--border-brand);
    transform: translateY(-1px);
}
.year-cell:disabled {
    cursor: default;
    transform: none;
    border-color: var(--border);
}

.year-cell--profit {
    background: linear-gradient(180deg, rgba(0, 255, 170, calc(0.06 + var(--pnl-i) * 0.16)) 0%, rgba(0, 255, 170, calc(0.02 + var(--pnl-i) * 0.10)) 100%);
    border-color: rgba(0, 255, 170, calc(0.14 + var(--pnl-i) * 0.18));
}
.year-cell--loss {
    background: linear-gradient(180deg, rgba(255, 77, 77, calc(0.06 + var(--pnl-i) * 0.16)) 0%, rgba(255, 77, 77, calc(0.02 + var(--pnl-i) * 0.10)) 100%);
    border-color: rgba(255, 77, 77, calc(0.14 + var(--pnl-i) * 0.18));
}
.year-cell--profit:hover { border-color: rgba(0, 255, 170, 0.55); }
.year-cell--loss:hover { border-color: rgba(255, 77, 77, 0.55); }

.year-cell--current {
    box-shadow: inset 0 0 0 2px var(--brand);
}

.year-month {
    align-self: end;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
}

.year-pnl {
    font-size: 1.6rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    line-height: 1.25;
    color: var(--text-muted);
}
.year-pnl.profit { color: #00ffaa; }
.year-pnl.loss { color: #ff5252; }

.year-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-self: start;
    gap: 4px 14px;
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
}
.year-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.3;
}
.year-stat-value {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-secondary);
}
.year-stat-label {
    font-size: 0.54rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    opacity: 0.65;
}
/* Best day of the month / best month of the year */
.cal-cell.cal-cell--best,
.year-cell.year-cell--best,
.year-cell.year-cell--best:hover {
    position: relative;
    border-color: var(--gold);
}
.best-star {
    position: absolute;
    top: 9px;
    right: 9px;
    color: var(--gold);
}

@media (max-width: 900px) {
    .year-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 640px) {
    .year-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
    .year-cell { min-height: 110px; padding: 12px 6px; }
    .year-pnl { font-size: 1.25rem; }
}

/* ═══════════════════════════════════════════════════════
   HISTORY VIEW
   ═══════════════════════════════════════════════════════ */

.history-header {
    margin-bottom: 20px;
}
.history-header h2 {
    font-size: 1.15rem;
    font-weight: 600;
}

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

.history-event {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: border-color var(--transition);
}
.history-event:hover {
    border-color: var(--border-brand);
}

.event-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    cursor: pointer;
    transition: background var(--transition);
}
.event-header:hover {
    background: rgba(255, 255, 255, 0.02);
}

.event-info {
    flex: 1;
    min-width: 0;
}

.event-title {
    font-size: 0.92rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.event-pnl {
    font-size: 1rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.event-pnl.profit { color: var(--green); }
.event-pnl.loss { color: var(--red); }

.event-expand-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
}
.event-expand-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
}
.event-expand-btn.expanded svg {
    transform: rotate(180deg);
}

.event-markets {
    border-top: 1px solid var(--border);
    padding: 4px 12px 12px;
}

.market-item {
    border-bottom: 1px solid var(--border);
}
.market-item:last-child {
    border-bottom: none;
}

.market-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 8px;
    cursor: pointer;
    transition: background var(--transition);
    border-radius: var(--radius-sm);
}
.market-header:hover {
    background: rgba(255, 255, 255, 0.02);
}

.market-pnl {
    font-size: 0.85rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.market-pnl.profit { color: var(--green); }
.market-pnl.loss { color: var(--red); }

.market-trade-count {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.market-trades {
    padding: 0 8px 8px;
}

.trades-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}

.trades-table th {
    text-align: left;
    padding: 6px 8px;
    font-weight: 600;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.trades-table td {
    padding: 6px 8px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    font-variant-numeric: tabular-nums;
}

.trades-table tr:last-child td {
    border-bottom: none;
}

.trades-table td:last-child {
    text-align: right;
    font-weight: 600;
}

.side-yes { color: var(--green); font-weight: 500; }
.side-no { color: var(--red); font-weight: 500; }

/* ── Hyperliquid position (round-trip) rows in History ── */
.hl-dir-chip {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 5px;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    margin-right: 8px;
    vertical-align: middle;
}
.hl-dir-long  { background: rgba(0, 212, 170, 0.16); color: var(--green); }
.hl-dir-short { background: rgba(255, 107, 107, 0.16); color: var(--red); }

.hl-pos-range {
    color: var(--text-secondary);
    font-size: 0.82rem;
    vertical-align: middle;
}

.hl-open-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #ff9f43;
    background: rgba(255, 159, 67, 0.14);
    border: 1px solid rgba(255, 159, 67, 0.3);
    vertical-align: middle;
}

.hl-action {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 5px;
    font-size: 0.7rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
}
.hl-action--open,
.hl-action--increase { color: #5298ff; background: rgba(82, 152, 255, 0.12); }
.hl-action--decrease { color: var(--brand-bright); background: rgba(187, 134, 252, 0.12); }
.hl-action--close,
.hl-action--flip     { color: #ff9f43; background: rgba(255, 159, 67, 0.14); }

.hl-buy  { color: var(--green); }
.hl-sell { color: var(--red); }

.trades-table--hl td { font-variant-numeric: tabular-nums; }

.event-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.event-title a {
    color: inherit;
    text-decoration: none;
}
.event-title a:hover .event-title-text {
    color: var(--brand-bright);
}

.event-ticker-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-elevated);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    letter-spacing: 0.02em;
    vertical-align: middle;
}

.event-source-badge {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 8px;
    border-radius: 999px;
    vertical-align: middle;
}
.event-source-badge--kalshi {
    background: rgba(0, 212, 170, 0.14);
    color: var(--green);
}
.event-source-badge--poly {
    background: rgba(82, 152, 255, 0.14);
    color: #5298ff;
}
.event-source-badge--hl {
    background: rgba(255, 159, 67, 0.16);
    color: #ff9f43;
}

.event-icon {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    object-fit: cover;
    margin-right: 8px;
    vertical-align: middle;
    border: 1px solid var(--border);
}

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

.market-ticker a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.85rem;
}
.market-ticker a:hover {
    color: var(--brand-bright);
}

.market-ticker-label {
    font-size: 0.62rem;
    color: var(--text-muted);
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    opacity: 0.7;
}

.history-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 24px 0 4px;
}

.hist-page-btn {
    padding: 8px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.hist-page-btn:hover:not(:disabled) {
    border-color: var(--brand-dim);
    color: var(--brand);
    background: var(--bg-card-hover);
}

.hist-page-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.hist-page-info {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.history-empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.history-empty svg {
    margin-bottom: 12px;
    opacity: 0.4;
}

/* ═══════════════════════════════════════════════════════
   POLYMARKET SAVED ACCOUNTS (compact list inside source-card)
   ═══════════════════════════════════════════════════════ */

.poly-saved-section {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.poly-saved-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.poly-saved-head-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    color: var(--text-muted);
}

.poly-saved-head-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.poly-saved-link {
    background: transparent;
    border: none;
    font-size: 0.72rem;
    color: var(--text-muted);
    padding: 3px 6px;
    cursor: pointer;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 120ms ease;
    font-family: inherit;
}

.poly-saved-link:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
}

.poly-saved-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 240px;
    overflow-y: auto;
    padding-right: 2px;
}

.poly-saved-list::-webkit-scrollbar { width: 6px; }
.poly-saved-list::-webkit-scrollbar-track { background: transparent; }
.poly-saved-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
}
.poly-saved-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.16);
}

.poly-saved-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 9px;
    cursor: pointer;
    transition: all 120ms ease;
    background: rgba(255, 255, 255, 0.015);
    user-select: none;
}

.poly-saved-row:hover {
    background: rgba(139, 92, 246, 0.06);
    border-color: rgba(139, 92, 246, 0.35);
}

.poly-saved-row--selected {
    background: rgba(139, 92, 246, 0.13);
    border-color: rgba(139, 92, 246, 0.55);
}

.poly-saved-check {
    width: 15px;
    height: 15px;
    border-radius: 4px;
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: white;
    background: transparent;
    transition: all 120ms ease;
}

.poly-saved-row--selected .poly-saved-check {
    background: #8b5cf6;
    border-color: #8b5cf6;
}

.poly-saved-check svg { opacity: 0; transition: opacity 120ms ease; }
.poly-saved-row--selected .poly-saved-check svg { opacity: 1; }

.poly-saved-pfp {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.05);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.poly-saved-pfp img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.poly-saved-pfp--csv {
    border-radius: 7px;
    background: rgba(16, 185, 129, 0.10);
    color: rgba(110, 231, 183, 0.9);
}

.poly-saved-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
    line-height: 1.25;
}

.poly-saved-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.poly-saved-addr {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: 0.01em;
}

.poly-saved-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

/* Profit badge - intentionally muted; it's an info signal, not a win/loss flag. */
.poly-saved-profit {
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.poly-saved-profit--pos { color: rgba(134, 239, 172, 0.72); }
.poly-saved-profit--neg { color: rgba(252, 165, 165, 0.72); }

/* ── Error / wrong-format CSV row ─────────────────────────────────────── */

.poly-saved-row--error {
    background: rgba(245, 158, 11, 0.05);
    border-color: rgba(245, 158, 11, 0.35);
    cursor: help;
    /* Top-align icons so they stay next to the first line when the error
       message wraps to multiple lines. */
    align-items: flex-start;
}

.poly-saved-row--error:hover {
    background: rgba(245, 158, 11, 0.10);
    border-color: rgba(245, 158, 11, 0.55);
}

.poly-saved-row--error .poly-saved-check,
.poly-saved-row--error .poly-saved-pfp,
.poly-saved-row--error .poly-saved-delete {
    margin-top: 1px;
}

.poly-saved-check--error {
    border-color: rgba(245, 158, 11, 0.55) !important;
    background: rgba(245, 158, 11, 0.15);
    color: rgba(252, 211, 77, 0.95);
}
.poly-saved-check--error svg { opacity: 1; }

.poly-saved-pfp--error {
    background: rgba(245, 158, 11, 0.12) !important;
    color: rgba(252, 211, 77, 0.95) !important;
}

.poly-saved-meta--error {
    color: rgba(252, 211, 77, 0.85);
    font-weight: 500;
    /* Override the base .poly-saved-meta truncation: error messages need to
       wrap fully so the user can read them without hovering. */
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.4;
    margin-top: 2px;
}

.poly-saved-delete {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px;
    border-radius: 5px;
    flex-shrink: 0;
    opacity: 0;
    transition: all 120ms ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.poly-saved-row:hover .poly-saved-delete { opacity: 0.7; }

.poly-saved-delete:hover {
    opacity: 1 !important;
    color: #f87171;
    background: rgba(239, 68, 68, 0.12);
}

/* ═══════════════════════════════════════════════════════
   SAVED CSVs - "Save to browser" controls + privacy header
   ═══════════════════════════════════════════════════════ */

/* Stack the section title with a tiny privacy line so the user always sees
   that this list lives entirely on their device. */
.poly-saved-head-titles {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.poly-saved-head-subtitle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.66rem;
    font-weight: 500;
    color: rgba(110, 231, 183, 0.85);
    text-transform: none;
    letter-spacing: 0;
    line-height: 1.1;
    cursor: help;
}

.poly-saved-head-subtitle svg {
    flex-shrink: 0;
    opacity: 0.85;
}

/* Wrap the name + persisted badge so the badge sits inline with the filename
   without breaking truncation behaviour. */
.poly-saved-name-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.poly-saved-name-row .poly-saved-name {
    flex: 0 1 auto;
    min-width: 0;
}

/* Tiny green lock pill for browser-saved CSVs - reads as "this is on your
   device" at a glance. */
.csv-persisted-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 6px 1px 5px;
    border-radius: 999px;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: rgba(16, 185, 129, 0.14);
    color: rgba(110, 231, 183, 0.95);
    border: 1px solid rgba(16, 185, 129, 0.32);
    line-height: 1;
    flex-shrink: 0;
    white-space: nowrap;
}
.csv-persisted-badge svg { opacity: 0.9; }

/* Per-row "Save" button. Subtle by default; hovering or selecting the row
   makes it more prominent. */
.csv-save-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 9px;
    border-radius: 7px;
    border: 1px solid rgba(187, 134, 252, 0.32);
    background: rgba(187, 134, 252, 0.08);
    color: var(--brand-bright);
    font-size: 0.7rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 140ms ease;
    flex-shrink: 0;
    line-height: 1;
}
.csv-save-btn:hover:not(:disabled) {
    background: rgba(187, 134, 252, 0.18);
    border-color: rgba(187, 134, 252, 0.55);
    color: #fff;
    transform: translateY(-1px);
}
.csv-save-btn:disabled {
    cursor: progress;
    opacity: 0.7;
}
.csv-save-btn svg {
    opacity: 0.85;
}

.csv-save-btn--loading {
    color: var(--text-secondary);
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.04);
}

.csv-spinner {
    animation: csv-spin 0.9s linear infinite;
}
@keyframes csv-spin {
    to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════
   2025-CSV ATTENTION CHIP + POPOVER (singleton in <body>)
   ═══════════════════════════════════════════════════════ */

.csv-2025-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid rgba(252, 211, 77, 0.45);
    background:
        radial-gradient(circle at 30% 30%, rgba(252, 211, 77, 0.35), transparent 70%),
        rgba(245, 158, 11, 0.10);
    color: rgba(253, 224, 71, 0.95);
    cursor: pointer;
    padding: 0;
    transition: all 160ms ease;
    box-shadow: 0 0 0 0 rgba(252, 211, 77, 0.45);
    flex-shrink: 0;
    font-family: inherit;
}
.csv-2025-icon:hover,
.csv-2025-icon:focus-visible {
    transform: scale(1.08);
    color: #fff;
    background:
        radial-gradient(circle at 30% 30%, rgba(252, 211, 77, 0.55), transparent 70%),
        rgba(245, 158, 11, 0.18);
    border-color: rgba(252, 211, 77, 0.75);
    box-shadow: 0 0 14px rgba(252, 211, 77, 0.45);
    outline: none;
}
.csv-2025-icon svg {
    position: relative;
    z-index: 2;
    filter: drop-shadow(0 0 4px rgba(252, 211, 77, 0.55));
}

/* Soft pulsing halo around the icon to call attention to it. */
.csv-2025-pulse {
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 1.5px solid rgba(252, 211, 77, 0.55);
    pointer-events: none;
    animation: csv-2025-pulse 2.2s ease-out infinite;
    opacity: 0;
}
@keyframes csv-2025-pulse {
    0%   { opacity: 0.85; transform: scale(0.85); }
    70%  { opacity: 0;    transform: scale(1.55); }
    100% { opacity: 0;    transform: scale(1.55); }
}

.csv-2025-popover {
    position: fixed;
    z-index: 200;
    width: 280px;
    padding: 14px 14px 12px;
    background: linear-gradient(180deg, rgba(28, 22, 12, 0.98), rgba(15, 15, 26, 0.98));
    border: 1px solid rgba(252, 211, 77, 0.32);
    border-radius: var(--radius-md);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(252, 211, 77, 0.08);
    color: var(--text-primary);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px) scale(0.97);
    transform-origin: top right;
    pointer-events: none;
    transition: opacity 160ms ease, transform 160ms ease, visibility 0s linear 160ms;
    text-align: left;
    line-height: 1.45;
    font-family: var(--font);
}

.csv-2025-popover.csv-2025-popover--open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    transition: opacity 160ms ease, transform 160ms ease, visibility 0s linear 0s;
}

.csv-2025-popover.csv-2025-popover--above {
    transform-origin: bottom right;
    transform: translateY(6px) scale(0.97);
}
.csv-2025-popover.csv-2025-popover--above.csv-2025-popover--open {
    transform: translateY(0) scale(1);
}

.csv-2025-popover-arrow {
    position: absolute;
    top: -6px;
    width: 10px;
    height: 10px;
    background: rgba(28, 22, 12, 0.98);
    border-top: 1px solid rgba(252, 211, 77, 0.32);
    border-left: 1px solid rgba(252, 211, 77, 0.32);
    transform: rotate(45deg);
}
.csv-2025-popover.csv-2025-popover--above .csv-2025-popover-arrow {
    top: auto;
    bottom: -6px;
    border-top: none;
    border-left: none;
    border-bottom: 1px solid rgba(252, 211, 77, 0.32);
    border-right: 1px solid rgba(252, 211, 77, 0.32);
}

.csv-2025-popover-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: rgba(253, 224, 71, 0.98);
    margin-bottom: 6px;
}
.csv-2025-popover-title svg {
    color: rgba(253, 224, 71, 0.9);
    flex-shrink: 0;
}

.csv-2025-popover-body {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.csv-2025-popover-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid rgba(252, 211, 77, 0.55);
    background: linear-gradient(135deg, rgba(252, 211, 77, 0.95) 0%, rgba(245, 158, 11, 0.95) 100%);
    color: #2a1e02;
    font-size: 0.78rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
    line-height: 1;
}
.csv-2025-popover-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(252, 211, 77, 0.32);
}
.csv-2025-popover-btn:disabled {
    opacity: 0.6;
    cursor: progress;
}
.csv-2025-popover-btn svg {
    opacity: 0.85;
}

.csv-2025-popover-foot {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 8px;
    font-size: 0.66rem;
    color: rgba(110, 231, 183, 0.78);
    font-weight: 500;
}
.csv-2025-popover-foot svg {
    flex-shrink: 0;
    opacity: 0.8;
}

/* When the popover is anchored on a row that's near the right edge of a
   narrow card, flip its anchor so it doesn't overflow horizontally. The
   .poly-saved-list parent already has overflow-y: auto so we can't rely on
   the page edge - we rely on the right-aligned anchor by default. */

@media (max-width: 540px) {
    .csv-2025-popover {
        width: 240px;
    }
}

/* ═══════════════════════════════════════════════════════
   STAGING CTA (View Chart button)
   ═══════════════════════════════════════════════════════ */

.staging-cta {
    width: 100%;
    max-width: 880px;
    margin: 24px auto 0;
    position: sticky;
    bottom: 16px;
    z-index: 50;
}

.staging-cta-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 20px;
    background: rgba(15, 15, 26, 0.92);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-brand);
    border-radius: var(--radius-lg);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(187, 134, 252, 0.08);
    flex-wrap: wrap;
}

.staging-cta-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 160px;
}

.staging-cta-count {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.staging-cta-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.btn-cta {
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 700;
    background: var(--brand-gradient);
    color: #fff;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 24px rgba(187, 134, 252, 0.35);
    letter-spacing: -0.01em;
    transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
}
.btn-cta:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 32px rgba(187, 134, 252, 0.5);
}
.btn-cta:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

/* ═══════════════════════════════════════════════════════
   POLY PROFILE CHIP (in-chart bar)
   ═══════════════════════════════════════════════════════ */

.csv-chip-pfp {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.csv-chip-name {
    font-weight: 600;
    color: var(--text-primary);
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════ */

@media (max-width: 640px) {
    .hero-title { font-size: 2.2rem; }
    .upload-card { padding: 32px 20px; }
    .app { padding: 72px 12px 32px; }
    .panel { padding: 20px 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .perf-columns { grid-template-columns: 1fr; }
    .entry-grid { grid-template-columns: repeat(2, 1fr); }
    .tab-btn { font-size: 0.8rem; padding: 8px 12px; }
    .event-header { padding: 12px 14px; gap: 10px; }
}
