/* ========================================
   BASE THEME (Original)
   ======================================== */
:root {
    --bg: #07080d;
    --panel: rgba(12, 16, 28, 0.78);
    --line: rgba(80, 120, 255, 0.25);
    --text: #e8f0ff;
    --muted: #9fb3d9;
    --cyan: #22d3ee;
    --magenta: #f472b6;
    --lime: #a3e635;
    --orange: #fb923c;
    --blue: #60a5fa;
    --green: #22c55e;
    --red: #ef4444;
    --font-main: "JetBrains Mono", "Space Grotesk", monospace;
    --font-display: "Space Grotesk", sans-serif;
    --radius: 14px;
    --panel-border: 1px solid var(--line);
    --layout-max-width: min(1600px, 95vw);
    --topbar-min-height: 64px;
    --body-bg: radial-gradient(600px 400px at 80% -10%, rgba(34, 211, 238, 0.25), transparent 60%),
                radial-gradient(900px 600px at 0% 20%, rgba(96, 165, 250, 0.2), transparent 60%),
                var(--bg);
}

/* ========================================
   GLOBAL STYLES
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    background: var(--body-bg);
    color: var(--text);
    min-height: 100vh;
}

.wrap {
    max-width: var(--layout-max-width);
    margin: 0 auto;
    padding: 26px;
    position: relative;
    z-index: 1;
}

.topbar {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 15px;
    margin-bottom: 18px;
    border: var(--panel-border);
    padding: 14px 16px;
    min-height: var(--topbar-min-height);
    border-radius: var(--radius);
    background: var(--panel);
    backdrop-filter: blur(8px);
}

.title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.3rem;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.title a {
    text-decoration: none;
}

.status {
    font-size: 0.8rem;
    color: var(--muted);
    white-space: nowrap;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

/* KPI Group Hierarchy */
.kpi-group-primary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.kpi-group-primary .kpi {
    border-left: 3px solid var(--cyan);
}

.kpi-group-secondary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
    margin-bottom: 18px;
}

.kpi-group-secondary .kpi {
    opacity: 0.8;
}

.kpi-group-secondary .kpi-value {
    font-size: 1.4rem;
}

.kpi {
    border: var(--panel-border);
    border-radius: var(--radius);
    background: var(--panel);
    padding: 14px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.kpi::after {
    content: "";
    position: absolute;
    inset: 0;
    border: 1px dashed rgba(255,255,255,0.05);
    border-radius: var(--radius);
    pointer-events: none;
}

.kpi-label {
    color: var(--muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.kpi-value {
    font-size: 1.35rem;
    margin-top: 8px;
    transition: text-shadow 0.3s ease;
}

.kpi-sub {
    font-size: 0.7rem;
    color: var(--muted);
    margin-top: 4px;
}

.grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 14px;
}

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

.panel {
    border: var(--panel-border);
    border-radius: var(--radius);
    background: var(--panel);
    padding: 14px;
    transition: all 0.3s ease;
}

.panel h2 {
    font-size: 0.85rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th, td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--line);
}

th {
    color: var(--muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: background 0.3s ease;
}

tr:hover td {
    background: rgba(255,255,255,0.02);
}

.pill {
    border: 1px solid var(--line);
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.7rem;
}

.tier-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.tier-badge {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    border: 1px solid rgba(255,255,255,0.08);
    background: transparent;
    color: var(--text);
}

.tier-S { border-color: #f5576c; }
.tier-A { border-color: #00f2fe; }
.tier-B { border-color: #38f9d7; }
.tier-C { border-color: #fee140; }
.tier-D { border-color: #d0d0d0; }
.tier-F { border-color: #8a8a8a; }

/* Search and Filter Styles */
.search-filter-container {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.search-input {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--line);
    color: var(--text);
    padding: 8px 14px;
    border-radius: 8px;
    font-family: var(--font-main);
    font-size: 0.85rem;
    width: 220px;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
}

.search-input:focus {
    border-color: var(--cyan);
    background: rgba(255, 255, 255, 0.12);
}

.search-input::placeholder {
    color: var(--muted);
    opacity: 0.7;
}

.tier-filter-select {
    background: var(--panel);
    border: 1px solid var(--line);
    color: var(--text);
    padding: 8px 12px;
    border-radius: 8px;
    font-family: var(--font-main);
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
}

.tier-filter-select:hover,
.tier-filter-select:focus {
    border-color: var(--cyan);
    background: rgba(30, 40, 60, 0.9);
}

.tier-filter-select option {
    background: #0c101c;
    color: var(--text);
}

.pagination-btn {
    padding: 8px 15px;
    background: var(--panel);
    border: 1px solid var(--line);
    color: var(--text);
    cursor: pointer;
    border-radius: 8px;
    font-family: var(--font-main);
    font-size: 0.85rem;
    transition: border-color 0.2s, background 0.2s;
}

.pagination-btn:hover:not(:disabled) {
    border-color: var(--cyan);
    background: rgba(30, 40, 60, 0.9);
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.loading {
    color: var(--muted);
    font-size: 0.85rem;
}

/* Skeleton Loading */
.skeleton-container {
    padding: 16px;
}

.skeleton-row {
    height: 14px;
    background: linear-gradient(90deg, var(--line) 25%, rgba(159,179,217,0.1) 50%, var(--line) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 10px;
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Row Flash on Update */
@keyframes row-flash {
    0% { background: rgba(34, 211, 238, 0.15); }
    100% { background: transparent; }
}

.row-flash {
    animation: row-flash 1.5s ease-out;
}

/* Density Control */
[data-density="compact"] table td,
[data-density="compact"] table th {
    padding: 4px 6px;
    font-size: 0.78rem;
}

[data-density="comfortable"] table td,
[data-density="comfortable"] table th {
    padding: 14px 12px;
    font-size: 0.95rem;
}

.section-gap {
    margin-top: 14px;
}

.positive { color: var(--green); }
.negative { color: var(--red); }
.multiplier-5x { color: #ffd700; text-shadow: 0 0 10px rgba(255, 215, 0, 0.5); }
.multiplier-2x { color: #22c55e; }
.multiplier-1x { color: #94a3b8; }
.wallet { font-family: var(--font-main); }
.score { font-weight: 600; }

.signal-badge {
    border: 1px solid var(--line);
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.7rem;
    display: inline-block;
}

.signal-buy { color: var(--green); }
.signal-sell { color: var(--red); }
.signal-strong-buy { color: var(--lime); }
.signal-strong-sell { color: var(--orange); }
.timestamp { color: var(--muted); font-size: 0.8rem; }

.toast-container {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.toast {
    background: rgba(12,16,28,0.95);
    border: 1px solid var(--line);
    color: var(--text);
    padding: 12px 18px;
    border-radius: 12px;
    font-size: 0.9rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.35);
    min-width: 220px;
    text-align: center;
}

.toast.success { border-color: rgba(34,197,94,0.6); color: #22c55e; }
.toast.error { border-color: rgba(239,68,68,0.6); color: #ef4444; }

/* Stat cards in P&L */
.stat-card {
    padding: 14px;
    background: rgba(12, 16, 28, 0.6);
    border-radius: 10px;
    border: 1px solid var(--line);
}

.stat-label {
    font-size: 0.7rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 1.3rem;
    font-weight: 600;
    margin-top: 4px;
}

/* Smaller fonts for telegram tables */
#tg-signals-container table,
#tg-trades-container table {
    font-size: 0.8rem;
}

#tg-signals-container th,
#tg-trades-container th {
    font-size: 0.65rem;
}

/* Smaller P&L summary cards */
#tg-pnl-container {
    font-size: 0.85rem;
}

/* KPI sparklines */
.kpi-sparkline {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 70px;
    height: 26px;
    opacity: 0.6;
}

/* KPI progress bars */
.kpi-progress {
    position: absolute;
    bottom: 10px;
    left: 14px;
    right: 14px;
    height: 4px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 2px;
    overflow: hidden;
}

.kpi-progress-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.6s ease;
}

/* Chart containers */
.chart-container {
    position: relative;
    height: 280px;
    width: 100%;
}

.chart-container canvas {
    max-width: 100%;
    max-height: 100%;
}

.charts-section .grid {
    margin-bottom: 0;
}

@media (max-width: 980px) {
    .charts-section .grid {
        grid-template-columns: 1fr !important;
    }
}

/* ========================================
   COMMAND PALETTE (Cmd+K)
   ======================================== */
.cmd-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 20vh;
}

.cmd-dialog {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 12px;
    width: min(560px, 90vw);
    max-height: 400px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.cmd-input {
    width: 100%;
    padding: 16px 20px;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--line);
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
    outline: none;
}

.cmd-results {
    max-height: 320px;
    overflow-y: auto;
}

.cmd-item {
    padding: 10px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text);
}

.cmd-item:hover,
.cmd-item.active {
    background: rgba(34, 211, 238, 0.1);
}

.cmd-item-icon {
    width: 20px;
    text-align: center;
    opacity: 0.6;
}

.cmd-item-label {
    flex: 1;
}

.cmd-item-shortcut {
    font-size: 11px;
    color: var(--muted);
    opacity: 0.5;
}

.cmd-item-type {
    font-size: 10px;
    color: var(--cyan);
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ========================================
   CONTEXT MENU (Right-Click)
   ======================================== */
.ctx-menu {
    position: fixed;
    z-index: 9998;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 4px 0;
    min-width: 180px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.ctx-item {
    padding: 8px 16px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
}

.ctx-item:hover {
    background: rgba(34, 211, 238, 0.1);
}

.ctx-sep {
    height: 1px;
    background: var(--line);
    margin: 4px 0;
}

/* ========================================
   DEVELOPER DETAIL MODAL
   ======================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9997;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 14px;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 24px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.2s, color 0.2s;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
}

.dev-detail-modal {
    padding: 24px;
}

.dev-detail-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    padding-right: 40px;
}

.dev-detail-tier {
    font-size: 2rem;
    font-weight: 700;
    padding: 8px 20px;
    border-radius: 12px;
    border: 2px solid;
}

.dev-detail-wallet {
    flex: 1;
}

.dev-detail-wallet-addr {
    font-family: var(--font-main);
    font-size: 12px;
    color: var(--muted);
    word-break: break-all;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dev-detail-wallet-addr button {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    transition: background 0.2s, color 0.2s;
}

.dev-detail-wallet-addr button:hover {
    background: rgba(34, 211, 238, 0.1);
    color: var(--cyan);
}

.dev-detail-score {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--cyan);
}

.dev-detail-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.dev-detail-stat {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.dev-detail-stat-label {
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

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

.dev-detail-links {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.dev-detail-link {
    flex: 1;
    padding: 10px;
    text-align: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    font-size: 12px;
    transition: background 0.2s, border-color 0.2s;
}

.dev-detail-link:hover {
    background: rgba(34, 211, 238, 0.1);
    border-color: var(--cyan);
}

.dev-detail-actions {
    display: flex;
    gap: 10px;
}

.dev-detail-action-btn {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    border: 1px solid;
}

.dev-detail-action-btn:hover {
    opacity: 0.85;
}

.dev-detail-action-btn.raybot {
    background: rgba(34, 197, 94, 0.15);
    border-color: var(--green);
    color: var(--green);
}

.dev-detail-action-btn.raybot.active {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--red);
    color: var(--red);
}

.dev-detail-action-btn.whitelist {
    background: rgba(234, 179, 8, 0.15);
    border-color: #eab308;
    color: #eab308;
}

.dev-detail-action-btn.whitelist.active {
    background: rgba(234, 179, 8, 0.3);
}

/* ========================================
   KEYBOARD SHORTCUTS HELP
   ======================================== */
.shortcuts-help {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px 20px;
    z-index: 9996;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    min-width: 220px;
}

.shortcuts-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--cyan);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.shortcuts-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 12px;
    color: var(--muted);
}

.shortcuts-list kbd {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 2px 6px;
    font-family: var(--font-main);
    font-size: 10px;
    color: var(--text);
    margin-right: 8px;
}

/* ========================================
   PANEL FOCUS STATE (Keyboard Navigation)
   ======================================== */
.panel.panel-focused {
    border-left: 3px solid var(--cyan);
}

/* ========================================
   RESPONSIVE - TABLET
   ======================================== */
@media (max-width: 1024px) {
    .wrap { padding: 16px; }
    .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
    .kpi-value { font-size: 1.3rem; }
    .grid { grid-template-columns: 1fr; }
}

/* ========================================
   RESPONSIVE - TABLET (Tables)
   ======================================== */
@media (max-width: 768px) {
    table { font-size: 12px; }
    .table-container, .card, .panel { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* ========================================
   RESPONSIVE - MOBILE
   ======================================== */
@media (max-width: 640px) {
    .wrap { padding: 10px; }
    .topbar { grid-template-columns: auto 1fr; gap: 8px; min-height: auto; }
    .topbar .status { display: none; } /* Hide on mobile */
    .ticker-wrap { display: none; } /* Hide ticker on small screens */
    .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
    .kpi { padding: 10px; }
    .kpi-label { font-size: 0.7rem; }
    .kpi-value { font-size: 1.1rem; }
    .kpi-sub { font-size: 0.65rem; }
    .panel { padding: 12px; margin-bottom: 8px; }
    .panel h2 { font-size: 1rem; }

    /* Horizontal scroll for tables */
    table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
    table thead, table tbody, table tr { display: table; width: 100%; table-layout: auto; }

    /* Stack grid panels */
    .grid { gap: 8px; }

    /* Smaller table fonts on mobile */
    table { font-size: 0.8rem; }
    th, td { padding: 6px 4px; }
    th { font-size: 0.6rem; }

    /* Command palette adjustments */
    .cmd-dialog { width: 95vw; }

    /* Modal adjustments */
    .modal-content { max-width: 95vw; }
    .shortcuts-help { display: none; }

    /* Toast adjustments */
    .toast-container { left: 10px; right: 10px; transform: none; }
    .toast { min-width: auto; width: 100%; }

    /* Channel cards responsive */
    .tg-channels-grid { grid-template-columns: 1fr !important; }
}

/* ========================================
   TELEGRAM P&L CHANNEL CARDS
   ======================================== */
.tg-channels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.tg-channel-card {
    background: rgba(12, 16, 28, 0.5);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px;
}

.tg-channel-name {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tg-channel-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.tg-ch-stat {
    text-align: center;
}

.tg-ch-stat-label {
    font-size: 0.6rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.tg-ch-stat-value {
    font-size: 1rem;
    font-weight: 600;
    margin-top: 2px;
}

.tg-pnl-summary {
    margin-top: 14px;
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--muted);
}
