/* Modern Tidy & Minimalist Design System for Trade Desk */
:root {
    --bg-main: #0b0d14;
    --bg-card: #151824;
    --bg-card-header: #11131d;
    --bg-card-hover: #1b1f2e;
    --border-color: #222738;
    --border-subtle: #191d2b;
    
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --color-green: #10b981;
    --color-green-dark: #047857;
    --color-red: #ef4444;
    --color-red-dark: #b91c1c;
    --accent-gold: #f59e0b;
    
    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    --shadow-card: 0 8px 24px -4px rgba(0, 0, 0, 0.4);
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    padding-bottom: 50px;
    overflow-x: hidden;
}

.app-container {
    width: 100%;
    max-width: 1240px;
    margin: 0 auto;
    padding: 16px 14px;
}

/* Top App Header */
.top-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
}

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

.brand-logo {
    width: 36px;
    height: 36px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.brand-text h1 {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.brand-subtitle {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Main Category Tabs */
.main-tabs {
    display: flex;
    align-items: center;
    background: #11131d;
    padding: 3px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: 0.8rem;
    border-radius: var(--radius-full);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.tab-btn.active {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #ffffff;
    box-shadow: 0 2px 10px rgba(245, 158, 11, 0.3);
}

.tab-badge {
    background: rgba(255, 255, 255, 0.15);
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 800;
}

.tab-btn.active .tab-badge {
    background: rgba(0, 0, 0, 0.25);
    color: #ffffff;
}

/* Tidy & Compact Control Panel (Stats + Date Filter in 1 Bar) */
.control-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 16px;
    margin: 16px 0;
    flex-wrap: wrap;
}

.stats-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.stat-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-card-header);
    border: 1px solid var(--border-subtle);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
}

.stat-pill .lbl {
    color: var(--text-muted);
    font-weight: 500;
}

.stat-pill .val {
    font-weight: 800;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

.stat-pill.highlight-green .val, .text-green {
    color: var(--color-green);
}

.text-red {
    color: var(--color-red);
}

/* Minimalist Inline Date Picker */
.date-inline-picker {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.date-lbl, .date-to-lbl {
    font-weight: 600;
}

.date-inline-picker input[type="date"] {
    background: var(--bg-card-header);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.78rem;
    outline: none;
    cursor: pointer;
}

.date-inline-picker input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
    opacity: 0.7;
}

.btn-clear-date {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-clear-date:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
}

/* Search & Outcome Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px 14px;
    flex: 1;
    min-width: 220px;
    color: var(--text-muted);
}

.search-box input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.84rem;
    font-family: var(--font-sans);
    width: 100%;
}

.filter-pills {
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-pill {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-pill.active {
    background: var(--border-color);
    color: #ffffff;
}

.filter-pill.profit-pill.active {
    background: rgba(16, 185, 129, 0.18);
    border-color: var(--color-green);
    color: var(--color-green);
}

.filter-pill.loss-pill.active {
    background: rgba(239, 68, 68, 0.18);
    border-color: var(--color-red);
    color: var(--color-red);
}

.sort-box select {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.78rem;
    outline: none;
    cursor: pointer;
}

/* Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
    gap: 18px;
}

/* Trade Card Component */
.trade-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    transition: transform 0.2s ease, border-color 0.2s ease;
    display: flex;
    flex-direction: column;
    position: relative;
}

.trade-card:hover {
    transform: translateY(-3px);
    border-color: #31384f;
}

/* Author Top Header inside card */
.card-author-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card-header);
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-subtle);
}

.author-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.author-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
}

.author-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary);
}

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

/* Card Body */
.card-main-content {
    padding: 16px 14px 12px 14px;
    position: relative;
    flex: 1;
}

/* Circular Stamp Watermark */
.stamp-closed {
    position: absolute;
    top: 36px;
    left: 50%;
    transform: translateX(-50%) rotate(-12deg);
    border: 2px dashed rgba(16, 185, 129, 0.35);
    color: rgba(16, 185, 129, 0.85);
    padding: 4px 12px;
    border-radius: 30px;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    pointer-events: none;
    background: rgba(16, 185, 129, 0.02);
    white-space: nowrap;
}

.stamp-closed.stamp-loss {
    border-color: rgba(239, 68, 68, 0.35);
    color: rgba(239, 68, 68, 0.85);
    background: rgba(239, 68, 68, 0.02);
}

/* Stock Meta Row */
.stock-meta-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 10px;
}

.stock-identity {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.stock-icon-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #ffffff;
    color: #111827;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
}

.stock-titles {
    min-width: 0;
}

.stock-titles h2 {
    font-size: 1rem;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stock-ticker {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}

.trade-action-badge {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    flex-shrink: 0;
}

.action-type {
    font-size: 1rem;
    font-weight: 900;
    letter-spacing: 0.04em;
}

.action-type.buy {
    color: #ffffff;
}

.action-type.sell {
    color: var(--color-red);
}

.trade-duration {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* Timestamps Right Column */
.timestamps-grid {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
    font-size: 0.7rem;
    margin-bottom: 18px;
    color: var(--text-muted);
}

.timestamp-item {
    display: flex;
    gap: 5px;
}

.timestamp-val {
    color: var(--text-secondary);
    font-weight: 600;
}

/* Price Progress Tracker Bar */
.price-tracker {
    margin-top: 8px;
    margin-bottom: 14px;
    padding: 0 2px;
}

.timeline-line-container {
    position: relative;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.timeline-track {
    position: absolute;
    top: 50%;
    left: 8px;
    right: 8px;
    height: 2px;
    background: var(--border-color);
    transform: translateY(-50%);
    border-style: dashed;
    z-index: 1;
}

.timeline-track-fill {
    position: absolute;
    top: 50%;
    height: 2px;
    transform: translateY(-50%);
    z-index: 2;
}

.timeline-track-fill.profit {
    background: var(--color-green);
}

.timeline-track-fill.loss {
    background: var(--color-red);
}

.node-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #374151;
    border: 2px solid var(--bg-card);
    position: relative;
    z-index: 3;
}

.node-dot.active-exit {
    width: 13px;
    height: 13px;
    background: var(--color-green);
    border: 2px solid #ffffff;
    box-shadow: 0 0 8px var(--color-green);
}

.node-dot.active-exit.loss {
    background: var(--color-red);
    box-shadow: 0 0 8px var(--color-red);
}

.node-dot.target-node.reached {
    background: var(--color-green);
}

/* Price Details Grid */
.price-values-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2px;
    text-align: center;
}

.price-col {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.price-lbl {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 600;
}

.price-num {
    font-size: 0.8rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

.price-num.target-val {
    color: var(--color-green);
}

.price-num.sl-val {
    color: var(--text-secondary);
}

/* Outcome Gradient Banner Footer */
.card-outcome-banner {
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 800;
    color: #ffffff;
    text-align: center;
}

.card-outcome-banner.banner-profit {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
}

.card-outcome-banner.banner-loss {
    background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
}

/* Card Social Footer */
.card-footer-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: var(--bg-card-header);
    border-top: 1px solid var(--border-subtle);
}

.action-btn-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.icon-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    min-height: 32px;
    transition: color 0.2s;
}

.icon-btn:hover {
    color: var(--text-primary);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-green);
    color: #ffffff;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 0.85rem;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    z-index: 999;
}

.hidden {
    display: none !important;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    margin-top: 20px;
}

.empty-icon {
    font-size: 2.2rem;
    margin-bottom: 8px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .control-panel {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .date-inline-picker {
        justify-content: space-between;
        width: 100%;
        border-top: 1px solid var(--border-subtle);
        padding-top: 8px;
    }

    .top-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .header-brand {
        justify-content: center;
    }

    .main-tabs {
        justify-content: space-around;
    }
}
