:root {
    --bg-color: #0f1115;
    --card-bg: rgba(23, 25, 30, 0.7);
    --text-primary: #ffffff;
    --text-secondary: #8b929a;
    --accent-color: #f7a600;
    /* Bybit yellow/orange tone */
    --positive: #00d68f;
    --negative: #ff4d4f;
    --font-family: 'Outfit', sans-serif;
    --glow: radial-gradient(circle at 50% -20%, rgba(247, 166, 0, 0.15), transparent 60%);
}


/* Search Styles */
.search-container {
    margin-bottom: 20px;
    width: 100%;
    max-width: 300px;
}

#search-input {
    width: 100%;
    padding: 10px 16px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-family: var(--font-family);
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
    text-align: center;
}

#search-input:focus {
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.1);
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    overflow-x: hidden;
}

.background-glow {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--glow);
    z-index: -1;
    pointer-events: none;
}

.container {
    width: 100%;
    max-width: 1200px;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

header {
    text-align: center;
    margin-bottom: 40px;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0;
    background: linear-gradient(135deg, #fff 0%, #aaa 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Dashboard Header */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 20px;
}

.search-container {
    width: 100%;
    max-width: 300px;
    margin: 0;
    /* Override previous margin */
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    width: 100%;
    margin-bottom: 30px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    backdrop-filter: blur(10px);
    transition: transform 0.2s, border-color 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.1);
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    font-family: 'Roboto Mono', monospace;
}

.sentiment-values {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: center;
    /* font-size: 1.8rem; Removed to avoid overflow */
    font-weight: 700;
    font-family: 'Roboto Mono', monospace;
}



/* Controls Bar */
/* Controls Bar */
.controls-bar {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
    /* Reduced to pull table closer */
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    gap: 30px;
    /* Space between items */
}

/* Ensure Search Container aligns properly in Controls Bar */
.controls-bar .search-container {
    width: auto;
    margin: 0;
    flex: 1;
    max-width: 300px;
    display: flex;
    justify-content: flex-end;
}

.controls-bar #search-input {
    width: 100%;
    text-align: left;
    padding-left: 16px;
}

.limit-tabs {
    background: rgba(255, 255, 255, 0.05);
    padding: 8px 16px;
    border-radius: 100px;
    display: flex;
    gap: 12px;
    align-items: center;
    margin-left: 0;
    font-size: 14px;
}






.limit-tab {
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s;
    font-weight: 500;
}

.limit-tab:hover {
    color: #fff;
}

.limit-tab.active {
    color: var(--primary-color);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 4px;
}

.tab-divider {
    color: var(--border-color);
    font-size: 12px;
}

/* Stats Dashboard */
/* Old Stats Dashboard removed/overridden by stats-grid */

/* Text Utility Classes */
.neutral-text {
    color: var(--text-secondary);
    font-weight: 600;
}

.positive-text {
    color: var(--positive) !important;
}

.negative-text {
    color: var(--negative) !important;
}

/* Table Styles */
.table-container {
    width: 100%;
    overflow-x: auto;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    margin-top: 0;
    /* Reduced from 24px */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
    /* Ensure horizontal scroll on small screens */
}

th,
td {
    padding: 12px 16px;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 14px;
}

th {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    backdrop-filter: blur(10px);
    /* Nice sticky effect */
    user-select: none;
}

/* Sortable Headers */
th.sortable {
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

th.sortable:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* Divider in stats */
.stat-divider {
    width: 1px;
    background: var(--border-color);
    align-self: stretch;
}

/* Sentiment Stats */
.sentiment-values {
    display: flex;
    gap: 8px;
    align-items: center;
}

.stat-sep {
    color: var(--text-secondary);
}

/* Left align first column */
th:first-child,
td:first-child {
    text-align: left;
}

/* Zebra Striping */
tbody tr {
    animation: fadeIn 0.3s ease-out forwards;
    opacity: 0;
    /*  Start invisible for animation */
}

tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

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

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

/* Column Specifics */
.col-symbol {
    display: flex;
    align-items: center;
    gap: 12px;
}

.rank {
    color: var(--text-secondary);
    font-size: 12px;
    min-width: 30px;
}

/* Base Coin Text */
.symbol-text {
    font-weight: 700;
    color: #fff;
}

/* Interval Badge (Merged into Rate) */
.interval-badge {
    font-family: 'Inter', sans-serif;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    font-size: 10px;
    padding: 2px 4px;
    border-radius: 4px;
    margin-left: 6px;
    font-weight: 400;
    vertical-align: middle;
}

.col-price {
    font-family: 'Roboto Mono', monospace;
    font-weight: 500;
    color: #fff;
    white-space: nowrap;
}

.col-volume {
    color: #fff;
    font-family: 'Roboto Mono', monospace;
    /* Monospace for numbers looks good */
}

.col-rate,
.col-apr {
    font-family: 'Roboto Mono', monospace;
    font-weight: 500;
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.remove-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.2s, color 0.2s;
}

.card:hover .remove-btn {
    opacity: 1;
}

.remove-btn:hover {
    color: var(--negative);
}

.data-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 12px;
}

.label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.value {
    font-size: 1.1rem;
    font-weight: 600;
}

.highlight {
    font-size: 1.8rem;
    font-weight: 700;
}

.positive {
    color: var(--positive);
}

.negative {
    color: var(--negative);
}

.neutral {
    color: var(--text-secondary);
    opacity: 0.8;
}

.loading {
    color: var(--text-secondary);
    font-style: italic;
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
}

footer {
    margin-top: 60px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.8rem;
    line-height: 1.5;
}

@media (max-width: 768px) {
    .container {
        padding: 20px 10px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .stat-card {
        padding: 16px;
    }

    .dashboard-header {
        flex-direction: column;
        align-items: center;
        gap: 20px;
        margin-bottom: 20px;
    }

    h1 {
        font-size: 2rem;
    }

    .controls-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
        padding-bottom: 20px;
    }

    .limit-tabs {
        width: 100%;
        margin-left: 0;
        justify-content: space-between;
        padding: 10px;
        overflow-x: auto;
        white-space: nowrap;
    }

    .limit-tab {
        font-size: 13px;
        padding: 4px;
    }

    .controls-bar .search-container {
        max-width: 100%;
        order: 3;
        /* Search at bottom */
    }

    .btn-snapshot {
        width: 100%;
        justify-content: center;
        padding: 10px;
        margin-right: 0;
        order: 2;
        /* Button below tabs */
    }

    /* Table Adjustments */
    th,
    td {
        padding: 10px 8px;
        font-size: 13px;
    }

    .col-volume {
        white-space: nowrap;
        /* Font size inherited (13px) for consistency */
    }

    .col-rate .interval-badge {
        display: inline-block;
        margin-left: 4px;
        font-size: 10px;
        /* Slightly larger but still compact */
        padding: 1px 4px;
        vertical-align: middle;
    }
}

/* Snapshot Styles */
.btn-snapshot {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    transition: all 0.2s;
    white-space: nowrap;
    margin-right: auto;
    /* Push search to the right if flex container allows */
}

.btn-snapshot:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: var(--accent-color);
}

.snapshot-section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.snapshot-section h3 {
    margin-top: 0;
    margin-bottom: 16px;
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.snapshot-list {
    display: grid;
    gap: 12px;
    max-height: 300px;
    overflow-y: auto;
}

.snapshot-item {
    background: rgba(0, 0, 0, 0.2);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

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

.snapshot-time {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.snapshot-label {
    font-weight: 600;
    color: var(--accent-color);
}

.snapshot-stats {
    display: flex;
    gap: 16px;
    font-size: 0.9rem;
    font-family: 'Roboto Mono', monospace;
    opacity: 0.9;
}

.delete-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0 4px;
}

.delete-btn:hover {
    color: var(--negative);
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    padding: 20px;
}

.snapshot-limit-badge {
    font-size: 0.8em;
    color: var(--text-secondary);
    font-weight: 400;
    margin-left: 6px;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

.history-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.history-header-row h3 {
    margin: 0;
}

.history-controls {
    display: flex;
    gap: 10px;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-color: var(--text-secondary);
}

.btn-danger {
    background: rgba(255, 77, 79, 0.1);
    border: 1px solid rgba(255, 77, 79, 0.2);
    color: var(--negative);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    transition: all 0.2s;
}

.btn-danger:hover {
    background: rgba(255, 77, 79, 0.2);
    border-color: var(--negative);
}

/* Ensure Save Button aligns content (icon + text) */
.btn-snapshot {
    display: flex;
    align-items: center;
}

/* History Table Styles */
.history-table-container {
    max-height: 500px;
    overflow-y: auto;
    margin-top: 0;
}

.col-date {
    color: var(--text-secondary);
    font-size: 0.9em;
    white-space: nowrap;
}

.col-label {
    font-weight: 600;
    color: var(--highlight-color);
}

.col-view {
    color: var(--text-secondary);
    font-size: 0.9em;
    font-style: italic;
}

.col-stat {
    font-family: 'Roboto Mono', monospace;
}

.col-action {
    text-align: center;
}

.edit-btn-table {
    background: rgba(247, 166, 0, 0.1);
    border: 1px solid rgba(247, 166, 0, 0.2);
    color: var(--accent-color);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
    transition: all 0.2s;
    margin-right: 6px;
}

.edit-btn-table:hover {
    background: rgba(247, 166, 0, 0.2);
    border-color: var(--accent-color);
}

.delete-btn-table {
    background: rgba(255, 77, 79, 0.1);
    border: 1px solid rgba(255, 77, 79, 0.2);
    color: var(--negative);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
    transition: all 0.2s;
}

.delete-btn-table:hover {
    background: rgba(255, 77, 79, 0.2);
    border-color: var(--negative);
}

/* Snapshot View Mode Styles */
.btn-exit-snapshot {
    background: rgba(255, 77, 79, 0.2);
    border: 1px solid rgba(255, 77, 79, 0.4);
    color: #ff4d4f;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
    white-space: nowrap;
    display: none;
    /* Hidden by default */
}

.btn-exit-snapshot:hover {
    background: rgba(255, 77, 79, 0.3);
    border-color: #ff4d4f;
    color: #fff;
}

.view-btn-table {
    background: rgba(0, 214, 143, 0.1);
    border: 1px solid rgba(0, 214, 143, 0.2);
    color: var(--positive);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
    transition: all 0.2s;
    margin-right: 6px;
}

.view-btn-table:hover {
    background: rgba(0, 214, 143, 0.2);
    border-color: var(--positive);
}

.snapshot-mode-indicator {
    background: rgba(247, 166, 0, 0.15);
    color: var(--accent-color);
    padding: 4px 12px;
    border-radius: 100px;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid rgba(247, 166, 0, 0.3);
    margin-left: 10px;
}