:root {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-hover: #334155;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --accent: #3b82f6;
    --green: #22c55e;
    --red: #ef4444;
    --orange: #f59e0b;
    --border: #334155;
    --exit-bg: rgba(245, 158, 11, 0.06);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

header {
    text-align: center;
    padding: 3rem 1rem 2rem;
    border-bottom: 1px solid var(--border);
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), var(--green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle { color: var(--text-muted); margin-top: 0.25rem; }
.updated { color: var(--text-muted); font-size: 0.8rem; margin-top: 0.5rem; }

main { max-width: 1100px; margin: 0 auto; padding: 2rem 1rem; }

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    border: 1px solid var(--border);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    border-color: rgba(59, 130, 246, 0.5);
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Period Tabs */
.period-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.tab {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.5rem 1.25rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.tab:hover { background: var(--surface-hover); }
.tab.active { background: var(--accent); color: white; border-color: var(--accent); }

/* Charts */
.charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.charts.collapsed { display: none; }

.chart-container {
    background: var(--surface);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid var(--border);
}

.chart-container h2 {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* Charts toggle */
.charts-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    margin-bottom: 1rem;
    transition: all 0.2s;
}

.charts-toggle:hover {
    border-color: var(--accent);
    color: var(--text);
}

.charts-toggle.collapsed #charts-toggle-icon {
    transform: rotate(-90deg);
}

#charts-toggle-icon {
    display: inline-block;
    transition: transform 0.2s;
    font-size: 0.7rem;
}

/* Summary Cards */
.summary-cards {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 2rem;
}

.summary-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}

.summary-group {}

.summary-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
    font-weight: 600;
}

.summary-items {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.summary-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0.2rem 0.6rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
    color: var(--text-muted);
}

.summary-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.summary-chip.active {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--accent);
    color: var(--accent);
}

.summary-chip .chip-count {
    background: var(--surface-hover);
    border-radius: 10px;
    padding: 0 0.35rem;
    font-size: 0.7rem;
    font-weight: 600;
}

/* Table */
.signals-section { margin-bottom: 3rem; }
.signals-section h2 { margin-bottom: 1rem; font-size: 1.25rem; }

.table-wrapper { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: 12px;
    overflow: hidden;
}

thead { background: #0f172a; }

th, td {
    padding: 1rem 1.25rem;
    text-align: left;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
}

th { 
    color: var(--text-muted); 
    font-weight: 600; 
    font-size: 0.75rem; 
    text-transform: uppercase; 
    letter-spacing: 0.05em; 
    border-bottom: 2px solid var(--border);
}
.loading { text-align: center; color: var(--text-muted); padding: 2rem; }

/* Row striping and Hover */
tbody tr:nth-child(even):not(.detail-row) { background: rgba(255, 255, 255, 0.02); }
tbody tr:not(.detail-row):hover { background: var(--surface-hover); transition: background 0.15s ease; }
tbody tr.expandable:hover { cursor: pointer; }
tbody tr.expandable td:first-child { position: relative; padding-left: 1.5rem; }
tbody tr.expandable td:first-child::before {
    content: "\25B6";
    position: absolute;
    left: 0.4rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.55rem;
    color: var(--text-muted);
    transition: transform 0.2s;
}

/* EXIT signal rows */
tr.signal-exit {
    background: var(--exit-bg) !important;
    opacity: 0.7;
}
tr.signal-exit:hover {
    opacity: 1;
    background: rgba(245, 158, 11, 0.12) !important;
}

/* Direction badges */
.dir-long { color: var(--green); font-weight: 600; }
.dir-short { color: var(--red); font-weight: 600; }
.dir-exit { color: var(--orange); font-weight: 600; font-size: 0.8rem; }

.pnl-positive { color: var(--green); font-weight: 600; }
.pnl-negative { color: var(--red); font-weight: 600; }
.outcome-win { color: var(--green); font-weight: 600; }
.outcome-loss { color: var(--red); font-weight: 600; }
.outcome-open { color: var(--orange); }
.outcome-exit { color: var(--text-muted); font-style: italic; }

.heat-bar { letter-spacing: -2px; }
.heat-none { color: var(--text-muted); letter-spacing: normal; }

/* Expandable detail rows */
.detail-row {
    display: none;
    background: rgba(59, 130, 246, 0.04) !important;
}

.detail-row.detail-visible {
    display: table-row;
}

.detail-row td {
    padding: 0.75rem 1.5rem 1rem;
    border-bottom: 2px solid var(--border);
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

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

.detail-value {
    font-size: 0.9rem;
    color: var(--text);
    font-weight: 500;
}

.detail-stop { color: var(--red); }
.detail-target { color: var(--green); }

/* CTA / Pricing */
.cta-section {
    text-align: center;
    padding: 3rem 0;
    border-top: 1px solid var(--border);
}

.cta-section h2 { font-size: 1.75rem; margin-bottom: 0.5rem; }
.cta-section > p { color: var(--text-muted); margin-bottom: 2rem; }

.pricing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    max-width: 960px;
    margin: 0 auto;
}

.price-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem 1.5rem;
    text-align: center;
    position: relative;
}

.price-card.featured {
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.15);
}

.popular-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.25rem 1rem;
    border-radius: 20px;
    letter-spacing: 0.05em;
}

.price-card h3 { font-size: 1.1rem; margin-bottom: 0.5rem; }

.price {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent);
}

.price span { font-size: 1rem; color: var(--text-muted); font-weight: 400; }

.price-card ul {
    list-style: none;
    margin: 1.5rem 0;
    text-align: left;
}

.price-card li {
    padding: 0.35rem 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.price-card li::before {
    content: "\2713";
    color: var(--green);
    margin-right: 0.5rem;
    font-weight: 700;
}

.btn {
    display: inline-block;
    padding: 0.75rem 2rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s;
    cursor: pointer;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover { background: #2563eb; }

.btn-outline {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
}

.btn-outline:hover { background: rgba(59, 130, 246, 0.1); }

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
}

/* Filter Bar */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--surface);
    border-radius: 8px 8px 0 0;
    border: 1px solid var(--border);
    border-bottom: none;
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(8px);
}

.filter-search {
    flex: 1;
    min-width: 160px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.filter-search:focus {
    outline: none;
    border-color: var(--accent);
}

.filter-search::placeholder { color: var(--text-muted); }

.filter-select {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.2s;
}

.filter-select:focus {
    outline: none;
    border-color: var(--accent);
}

.filter-clear {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-clear:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.filter-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-left: auto;
    white-space: nowrap;
}

/* Pager */
.table-pager {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem;
    background: var(--surface);
    border-radius: 0 0 12px 12px;
    border: 1px solid var(--border);
    border-top: none;
    flex-wrap: wrap;
}

.pager-btn {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    padding: 0.3rem 0.6rem;
    font-size: 0.82rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
    min-width: 36px;
}

.pager-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.pager-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    font-weight: 600;
}

.pager-ellipsis {
    color: var(--text-muted);
    padding: 0 0.25rem;
}

/* Signal view table-wrapper border-top for filter bar gap */
#view-active .table-wrapper,
#view-watchlist .table-wrapper,
#view-closed .table-wrapper {
    border-radius: 0 0 12px 12px;
    border-top: none;
}

.table-wrapper.filtered {
    border-radius: 12px;
}

/* No results row */
.no-results td {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
    font-style: italic;
}

/* Signal Tabs */
.signal-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 0;
    border-bottom: 2px solid var(--border);
}

.signal-tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}

.signal-tab:hover { color: var(--text); }
.signal-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-count {
    display: inline-block;
    background: var(--surface-hover);
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    margin-left: 0.25rem;
}

.signal-tab.active .tab-count {
    background: rgba(59, 130, 246, 0.2);
    color: var(--accent);
}

/* Signal Views */
.signal-view { display: none; }
.signal-view.visible { display: block; }

/* Trigger Badges */
.trigger-imminent {
    display: inline-block;
    background: rgba(245, 158, 11, 0.15);
    color: var(--orange);
    font-weight: 700;
    font-size: 0.8rem;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    letter-spacing: 0.03em;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.trigger-watchlist {
    display: inline-block;
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
}

/* Responsive */
@media (max-width: 768px) {
    .charts { grid-template-columns: 1fr; }
    .pricing-grid { grid-template-columns: 1fr 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .detail-grid { grid-template-columns: repeat(2, 1fr); }
    .summary-row { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
    .pricing-grid { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
    .summary-row { grid-template-columns: 1fr; }
}
