/**
 * JerryTrades v4 — Team Needs Grid CSS
 * Modal overlay with league-wide positional needs matrix
 */

/* ── Overlay & Modal ─────────────────────────────────────────────────── */

#teamNeedsGrid {
    position: fixed;
    inset: 0;
    z-index: 1200;
    pointer-events: auto;
}

#teamNeedsGrid .tng-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(2px);
}

#teamNeedsGrid .tng-modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(720px, 99vw);
    height: min(78vh, 700px);
    background: #111827;
    border: 1px solid #1f2937;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}

/* ── Header ──────────────────────────────────────────────────────────── */

.tng-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.1rem 0.7rem;
    border-bottom: 1px solid #1f2937;
    flex-shrink: 0;
}

.tng-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #f9fafb;
    letter-spacing: -0.01em;
}

.tng-header-right {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.tng-search {
    background: #1f2937;
    border: 1px solid #374151;
    border-radius: 6px;
    color: #f9fafb;
    font-size: 0.8rem;
    padding: 0.3rem 0.65rem;
    width: 160px;
    outline: none;
}
.tng-search:focus { border-color: #7c3aed; }
.tng-search::placeholder { color: #6b7280; }

.tng-close {
    background: #374151;
    border: none;
    border-radius: 6px;
    color: #9ca3af;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0.3rem 0.6rem;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
}
.tng-close:hover { background: #4b5563; color: #f9fafb; }

/* ── Legend ──────────────────────────────────────────────────────────── */

.tng-legend {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.1rem;
    border-bottom: 1px solid #1f2937;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.tng-chip {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.55rem;
    border-radius: 99px;
    letter-spacing: 0.03em;
}

/* Tier colours — also used on cells */
.tng-chip.tng-over, .tng-over .tng-tier-dot  { background: rgba(52, 211, 153, 0.18); color: #34d399; border: 1px solid rgba(52, 211, 153, 0.3); }
.tng-chip.tng-set,  .tng-set  .tng-tier-dot  { background: rgba(99, 102, 241, 0.18); color: #818cf8; border: 1px solid rgba(99, 102, 241, 0.3); }
.tng-chip.tng-thin, .tng-thin .tng-tier-dot  { background: rgba(251, 191, 36, 0.18); color: #fbbf24; border: 1px solid rgba(251, 191, 36, 0.3); }
.tng-chip.tng-weak, .tng-weak .tng-tier-dot  { background: rgba(248, 113, 113, 0.18); color: #f87171; border: 1px solid rgba(248, 113, 113, 0.3); }

.tng-legend-note {
    font-size: 0.68rem;
    color: #6b7280;
    margin-left: auto;
}

/* ── Table Wrapper ───────────────────────────────────────────────────── */

.tng-table-wrap {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    padding: 0;
}

/* Custom scrollbar */
.tng-table-wrap::-webkit-scrollbar { width: 5px; height: 5px; }
.tng-table-wrap::-webkit-scrollbar-track { background: transparent; }
.tng-table-wrap::-webkit-scrollbar-thumb { background: #374151; border-radius: 99px; }

/* ── Table ───────────────────────────────────────────────────────────── */

.tng-table {
    min-width: 700px;   /* team(200) + 4×pos(100ea) + intel(140) = 740 */
    width: max-content; /* shrink to content; scroll wrapper handles overflow */
    border-collapse: collapse;
    font-size: 0.82rem;
    table-layout: fixed;
}

/* Header */
.tng-th {
    background: #0f172a;
    color: #6b7280;
    width: 90px;  /* fixed width for all position columns */
    font-size: 0.73rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.55rem 0.5rem;
    text-align: center;
    border-bottom: 1px solid #1f2937;
    white-space: nowrap;
    user-select: none;
    cursor: pointer;
    position: sticky;
    top: 0;
    z-index: 2;
    transition: color 0.15s;
}
.tng-th:hover { color: #d1d5db; }
.tng-th.tng-sorted { color: #7c3aed; }
.tng-th-team {
    text-align: left;
    padding-left: 1rem;
    width: 180px;
    min-width: 160px;
    cursor: default;
}
.tng-sort-icon { margin-left: 3px; font-size: 0.65rem; opacity: 0.5; }

/* Rows */
.tng-row {
    transition: background 0.12s;
}
.tng-row:hover { background: rgba(255,255,255,0.03); }
.tng-row:not(:last-child) td { border-bottom: 1px solid #1a2332; }

/* My-team row */
.tng-my-team { background: rgba(124, 58, 237, 0.07); }
.tng-my-team:hover { background: rgba(124, 58, 237, 0.12); }

/* Dim rows when cell is clicked for opportunity highlight */
.tng-row-dim td { opacity: 0.3; transition: opacity 0.2s; }

/* Team name column */
.tng-team-name {
    padding: 0.55rem 0.6rem 0.55rem 1rem;
    color: #d1d5db;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
}

.tng-me-badge {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 700;
    background: #7c3aed;
    color: #fff;
    border-radius: 4px;
    padding: 0 4px;
    margin-right: 5px;
    letter-spacing: 0.05em;
    vertical-align: middle;
}

/* Data cells */
.tng-cell {
    padding: 0.45rem 0.35rem;
    text-align: center;
    cursor: pointer;
    transition: opacity 0.2s, filter 0.2s;
    position: relative;
}

.tng-pct {
    font-size: 0.78rem;
    font-weight: 600;
    display: block;
}

.tng-tier-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-top: 2px;
}

/* Cell tier background tints */
.tng-cell.tng-over { background: rgba(52, 211, 153, 0.07); }
.tng-cell.tng-set  { background: transparent; }
.tng-cell.tng-thin { background: rgba(251, 191, 36, 0.06); }
.tng-cell.tng-weak { background: rgba(248, 113, 113, 0.08); }

/* Cell text colours per tier */
.tng-cell.tng-over .tng-pct { color: #34d399; }
.tng-cell.tng-set  .tng-pct { color: #818cf8; }
.tng-cell.tng-thin .tng-pct { color: #fbbf24; }
.tng-cell.tng-weak .tng-pct { color: #f87171; }

/* Tier dot colours */
.tng-cell.tng-over .tng-tier-dot { background: #34d399; }
.tng-cell.tng-set  .tng-tier-dot { background: #818cf8; }
.tng-cell.tng-thin .tng-tier-dot { background: #fbbf24; }
.tng-cell.tng-weak .tng-tier-dot { background: #f87171; }

/* Highlighted cell (from opportunity click) */
.tng-cell.tng-highlight {
    outline: 2px solid #7c3aed;
    outline-offset: -2px;
    border-radius: 3px;
    z-index: 1;
}
.tng-cell.tng-highlight-origin {
    outline-color: #a78bfa;
    background: rgba(124, 58, 237, 0.18) !important;
}

/* ── Footer ──────────────────────────────────────────────────────────── */

.tng-footer {
    padding: 0.5rem 1.1rem;
    font-size: 0.7rem;
    color: #6b7280;
    border-top: 1px solid #1f2937;
    flex-shrink: 0;
}

/* ── Mobile ──────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
    #teamNeedsGrid .tng-modal {
        top: auto;
        left: 0;
        bottom: 0;
        transform: none;
        width: 100%;
        min-width: 100%;
        height: auto;
        max-height: 90vh;
        border-radius: 12px 12px 0 0;
        overflow: hidden;
    }

    /* Also need the table-wrap itself to clip its vertical overflow
       since the modal no longer does it: */
    .tng-table-wrap {
        overflow-x: auto;
        overflow-y: auto;
        /* Ensure it doesn't overflow the modal's rounded corners */
        border-radius: 0 0 12px 12px;
    }
    .tng-legend-note { display: none; }
    .tng-search { width: 100px; }

    /* Override table min-width — mobile columns are much narrower than the 700px default.
       team(85) + 4×pos(68) + intel(76) = 433px. Allow the table to shrink to that. */
    .tng-table {
        /* Modal is now exactly 402px. Table must be wider for tng-table-wrap to scroll.
           85(team) + 4×68(pos) + 76(Jerry) = 433px content + 80px buffer = 513px */
        width: 513px !important;
        min-width: 513px !important;
    }

    /* Team column: narrow with text wrap (no ellipsis) so names fit in ~85px */
    .tng-th-team {
        width: 85px;
        min-width: 75px;
        padding-left: 0.5rem;
    }
    .tng-team-name {
        width: 85px;
        min-width: 75px;
        font-size: 0.72rem;
        padding-left: 0.5rem;
        white-space: normal;       /* allow name to wrap to 2 lines */
        overflow: visible;
        text-overflow: clip;
        line-height: 1.25;
    }

    /* Narrow all position columns */
    .tng-th { width: 68px; }
    .tng-cell { width: 68px; }

    /* Compact Jerry's Thoughts column */
    .tng-th-intel { width: 76px; min-width: 76px; }
    .tng-analyze-cell { width: 76px; padding: 0.25rem; }
    .tng-analyze-btn {
        font-size: 0.62rem;
        padding: 3px 5px;
        white-space: normal;
        line-height: 1.2;
    }

    /* Jerry's Thoughts side panel — bottom sheet on mobile */
    .fi-panel {
        position: fixed;
        top: auto;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 60vh;
        border-left: none;
        border-top: 1px solid rgba(255,255,255,0.15);
        border-radius: 12px 12px 0 0;
        z-index: 1210;
    }
}

/* ── Loading State ───────────────────────────────────────────────────── */

.tng-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    gap: 1rem;
    flex: 1;
}

.tng-loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #1f2937;
    border-top-color: #7c3aed;
    border-radius: 50%;
    animation: tngSpin 0.7s linear infinite;
}

@keyframes tngSpin {
    to { transform: rotate(360deg); }
}

.tng-loading-text {
    font-size: 0.85rem;
    color: #6b7280;
}

/* ── Needs Grid button in trading toolbar ────────────────────────────── */

.trade-action-btn.needs-grid-btn {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.35);
    color: #a5b4fc;
}
.trade-action-btn.needs-grid-btn:hover {
    background: rgba(99, 102, 241, 0.28);
    border-color: #7c3aed;
    color: #c4b5fd;
}

/* ── Franchise Intel Panel ──────────────────────────────────── */
.fi-panel {
    position: absolute;
    top: 0; right: 0;
    width: 400px;
    height: 100%;
    background: #1a1f2e;
    border-left: 1px solid rgba(255,255,255,0.1);
    display: flex;
    flex-direction: column;
    z-index: 10;
    overflow: hidden;
}
.fi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #242938;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}
.fi-title { font-weight: 600; color: #e2e8f0; }
.fi-close { background: none; border: none; color: #94a3b8; cursor: pointer; font-size: 1.1em; }
.fi-franchise-name {
    padding: 8px 16px;
    font-size: 0.95em;
    font-weight: 600;
    color: #48bb78;
    background: #1e2535;
    flex-shrink: 0;
}
.fi-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    font-size: 0.85em;
    line-height: 1.6;
    color: #cbd5e0;
}
.fi-loading { color: #94a3b8; font-style: italic; }
.fi-error { color: #fc8181; }
.fi-section-header {
    color: #63b3ed;
    font-size: 1em;
    margin: 14px 0 6px;
    border-bottom: 1px solid rgba(99,179,237,0.2);
    padding-bottom: 3px;
}
.fi-sub-header { color: #90cdf4; font-size: 0.9em; margin: 8px 0 4px; }

/* Notes bar — always visible, non-blocking optional context */
.fi-notes-bar {
    padding: 6px 12px 4px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}
.fi-notes-input {
    width: 100%;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 5px;
    color: #94a3b8;
    font-size: 0.75rem;
    line-height: 1.4;
    padding: 5px 8px;
    resize: none;
    box-sizing: border-box;
    transition: border-color 0.15s;
}
.fi-notes-input:focus {
    outline: none;
    border-color: rgba(99,179,237,0.35);
    color: #e2e8f0;
}
.fi-notes-input::placeholder { color: #374151; }

/* Cached result indicator in share toolbar */
.fi-cache-badge {
    font-size: 11px;
    color: var(--text-muted, #888);
    padding: 4px 8px;
    opacity: 0.7;
    user-select: none;
}

/* ── Franchise Intel Tabs ─────────────────────────────────────── */
.fi-header-tabs { display: flex; gap: 4px; margin: 0 8px; }
.fi-tab {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    color: #6b7280;
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 3px 10px;
    transition: background 0.15s, color 0.15s;
}
.fi-tab:hover { color: #cbd5e0; background: rgba(255,255,255,0.1); }
.fi-tab.fi-tab-active {
    background: rgba(99,179,237,0.15);
    border-color: rgba(99,179,237,0.4);
    color: #63b3ed;
}
.fi-tab-pane { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.fi-tab-pane-hidden { display: none !important; }

/* ── Franchise Intel Roster Tab ───────────────────────────────── */
.fi-roster-content { padding: 8px 12px; overflow-y: auto; flex: 1; }
.fir-table { display: flex; flex-direction: column; gap: 6px; }
.fir-pos-section { display: flex; gap: 6px; align-items: flex-start; }
.fir-pos-label {
    width: 30px;
    min-width: 30px;
    text-align: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: #fff;
    border-radius: 4px;
    padding: 3px 0;
    margin-top: 2px;
}
.fir-players { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.fir-player {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    flex-wrap: wrap;
    padding: 2px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.fir-name { color: #e2e8f0; font-weight: 500; flex: 1; min-width: 100px; }
.fir-team { color: #6b7280; font-size: 0.7rem; }
.fir-inj { background: rgba(248,113,113,0.15); color: #f87171; border-radius: 3px; font-size: 0.65rem; padding: 1px 4px; }
.fir-contract { color: #94a3b8; font-size: 0.7rem; }
.fir-ktc { color: #48bb78; font-size: 0.7rem; font-variant-numeric: tabular-nums; }
.fir-ktc-zero { color: #4b5563; }

/* Intel column header — no sort icon, narrow fixed width */
.tng-th-intel {
    width: 140px;
    min-width: 140px;
    cursor: default;
    text-align: center;
}
.tng-th-intel:hover { color: #6b7280; } /* suppress hover on non-sortable col */

/* Analyze cell — centers the button */
.tng-analyze-cell {
    padding: 0.3rem 0.5rem;
    text-align: center;
    white-space: nowrap;
    width: 140px;
}

/* "Jerry's Thoughts" button */
.tng-analyze-btn {
    background: rgba(99,179,237,0.08);
    border: 1px solid rgba(99,179,237,0.35);
    border-radius: 5px;
    color: #63b3ed;
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    padding: 4px 10px;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.tng-analyze-btn:hover {
    background: rgba(99,179,237,0.2);
    border-color: rgba(99,179,237,0.6);
}

/* Make tng-modal relatively positioned to contain the panel */
.tng-modal { position: relative; overflow: hidden; }

/* Franchise Intel content typography */
.fi-stream-output { font-size: 0.85em; line-height: 1.65; color: #cbd5e0; }
.fi-para { margin: 0 0 8px; }
.fi-para:last-child { margin-bottom: 0; }
.fi-spacer { height: 10px; }
.fi-list { margin: 4px 0 10px 1.1em; padding: 0; }
.fi-list li { margin-bottom: 5px; }
.fi-numbered { margin: 3px 0; }

/* Share toolbar below intel stream */
.fi-share-toolbar {
    display: flex;
    gap: 8px;
    padding: 10px 16px 14px;
    border-top: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
}
.fi-share-btn {
    flex: 1;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 5px;
    color: #94a3b8;
    cursor: pointer;
    font-size: 0.75rem;
    padding: 6px 10px;
    transition: background 0.15s, color 0.15s;
}
.fi-share-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #e2e8f0;
}

/* ── Franchise Intel loading animation ───────────────────────────────────── */
.fi-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 32px 16px;
    color: var(--text-secondary, #94a3b8);
}

.fi-loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color, #334155);
    border-top-color: var(--accent-color, #22d3ee);
    border-radius: 50%;
    animation: fi-spin 0.9s linear infinite;
}

.fi-loading-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #e2e8f0);
}

.fi-loading-sub {
    font-size: 12px;
    opacity: 0.6;
    animation: fi-pulse 2s ease-in-out infinite;
}

@keyframes fi-spin {
    to { transform: rotate(360deg); }
}

@keyframes fi-pulse {
    0%, 100% { opacity: 0.6; }
    50%       { opacity: 1.0; }
}

/* ── Top-level tab bar (Needs Matrix | Trade Intel) ─────────────────────── */
.tng-main-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background: #1a1f2e;
    flex-shrink: 0;
}
.tng-main-tab {
    padding: 0.55rem 1.1rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: #6b7280;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.tng-main-tab:hover { color: #d1d5db; }
.tng-main-tab.tng-main-tab-active {
    color: #a78bfa;
    border-bottom-color: #7c3aed;
}

/* ── Pane containers ────────────────────────────────────────────────────── */
/* Each pane fills all remaining space after header + tabs */
.tng-pane {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;  /* inner scrollable children handle their own overflow */
    min-height: 0;
}
.tng-pane-hidden { display: none; }

/* ── Trade Intel tab content ─────────────────────────────────────────────── */
.tng-ti-content {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Empty state */
.tng-ti-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 3rem 2rem;
    text-align: center;
    color: #6b7280;
}
.tng-ti-empty-icon  { font-size: 2.2rem; }
.tng-ti-empty-title { font-size: 0.95rem; font-weight: 600; color: #9ca3af; }
.tng-ti-empty-sub   { font-size: 0.8rem; line-height: 1.5; max-width: 320px; }
.tng-ti-empty-sub strong { color: #d1d5db; }

/* Header band */
.tng-ti-header {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.5rem 0 0.65rem;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    margin-bottom: 0.5rem;
    flex-shrink: 0;
}
.tng-ti-header-label { font-size: 0.82rem; font-weight: 600; color: #e2e8f0; }
.tng-ti-header-sub   { font-size: 0.7rem; color: #6b7280; }

/* Rows list */
.tng-ti-rows { display: flex; flex-direction: column; gap: 0; }

/* Summary row (clickable) */
.tng-ti-row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.45rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.12s;
    flex-wrap: nowrap;
    /* bar-col inside handles its own vertical stacking — row stays single-line */
}

/* Jerry's Thoughts button on Trade Intel rows — reuses .tng-analyze-btn base styles
   but needs flex-shrink:0 so the bar doesn't squish it out. */
.tng-ti-row .tng-analyze-btn {
    flex-shrink: 0;
    margin-left: auto;  /* push to far right, mirroring the Needs Matrix column layout */
    font-size: 0.7rem;
    padding: 0.2rem 0.55rem;
}
.tng-ti-row:hover     { background: #1f2937; }
.tng-ti-row-me        { background: rgba(99,102,241,0.08); }
.tng-ti-row-open      { background: #1f2937; border-radius: 6px 6px 0 0; }

.tng-ti-row-name {
    min-width: 8rem;
    max-width: 10rem;
    font-size: 0.78rem;
    font-weight: 500;
    color: #d1d5db;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-shrink: 0;
}

/* Activity bar column — wraps the bar + score sub-text vertically */
.tng-ti-bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 4rem;
}
.tng-ti-bar-wrap {
    height: 6px;
    background: #374151;
    border-radius: 3px;
    overflow: hidden;
    width: 100%;
}
.tng-ti-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}
/* Weighted score sub-line — visible on desktop, always visible on mobile */
.tng-ti-bar-score {
    font-size: 0.58rem;
    color: #4b5563;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1;
}
/* On narrow screens where tooltip is unavailable, always show the sub-line */
@media (hover: none) {
    .tng-ti-bar-score { color: #6b7280; }
}
.tng-ti-bar-fill.tng-ti-cat-high { background: #10b981; }
.tng-ti-bar-fill.tng-ti-cat-mid  { background: #f59e0b; }
.tng-ti-bar-fill.tng-ti-cat-low  { background: #4338ca; }

/* Category badge */
.tng-ti-cat-badge {
    font-size: 0.62rem;
    font-weight: 700;
    padding: 0.08rem 0.4rem;
    border-radius: 10px;
    white-space: nowrap;
    flex-shrink: 0;
}
.tng-ti-cat-high { background: #064e3b; color: #6ee7b7; border: 1px solid #10b981; }
.tng-ti-cat-mid  { background: #451a03; color: #fcd34d; border: 1px solid #f59e0b; }
.tng-ti-cat-low  { background: #1e1b4b; color: #a5b4fc; border: 1px solid #4338ca; }

/* Position affinity chips (top-3 summary) */
.tng-ti-pos-chips { display: flex; gap: 0.2rem; flex-shrink: 0; }
.tng-ti-pos-chip {
    background: #374151;
    border-radius: 3px;
    padding: 0.05rem 0.3rem;
    font-size: 0.62rem;
    color: #9ca3af;
    font-weight: 600;
}

/* Expand caret */
.tng-ti-expand-icon {
    color: #4b5563;
    font-size: 0.65rem;
    flex-shrink: 0;
    transition: transform 0.15s;
}
.tng-ti-row-open .tng-ti-expand-icon { transform: rotate(90deg); }

/* ── Detail accordion (hidden by default) ───────────────────────────────── */
.tng-ti-detail {
    background: #111827;
    border: 1px solid #1f2937;
    border-top: none;
    border-radius: 0 0 6px 6px;
    padding: 0.65rem 0.8rem;
    display: flex;
    gap: 1.2rem;
    flex-wrap: wrap;
    margin-bottom: 0.35rem;
}
.tng-ti-detail-hidden { display: none; }

.tng-ti-section {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 10rem;
    flex: 1;
}
.tng-ti-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    margin-bottom: 0.3rem;
}

/* Position bars in detail */
.tng-ti-pos-rows { display: flex; flex-direction: column; gap: 0.25rem; }
.tng-ti-pos-row  { display: flex; align-items: center; gap: 0.4rem; font-size: 0.72rem; }
.tng-ti-pos-name { color: #d1d5db; font-weight: 600; min-width: 2rem; flex-shrink: 0; }
.tng-ti-pos-bar-wrap {
    flex: 1;
    height: 5px;
    background: #1f2937;
    border-radius: 2px;
    overflow: hidden;
}
.tng-ti-pos-bar {
    height: 100%;
    background: #7c3aed;
    border-radius: 2px;
}
.tng-ti-pos-wt  { color: #6b7280; font-size: 0.65rem; min-width: 2rem; text-align: right; flex-shrink: 0; }

/* Year-by-year bars in detail */
.tng-ti-yr-rows { display: flex; flex-direction: column; gap: 0.35rem; }
.tng-ti-yr-row  { display: flex; align-items: center; gap: 0.4rem; font-size: 0.72rem; }
.tng-ti-yr-label { color: #9ca3af; min-width: 2.5rem; flex-shrink: 0; }

/* Two stacked bar tracks per year row */
.tng-ti-yr-bars {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.tng-ti-yr-track {
    height: 4px;
    background: #1f2937;
    border-radius: 2px;
    overflow: hidden;
}
/* 🟦 Top bar: cyan — % of ALL league trades in that year (market share) */
.tng-ti-yr-bar-league { height: 100%; background: #0ea5e9; border-radius: 2px; }
/* 🟪 Bottom bar: purple — % of franchise's own 5yr trade total in that year */
.tng-ti-yr-bar-own    { height: 100%; background: #7c3aed; opacity: 0.85; border-radius: 2px; }

.tng-ti-yr-ct { color: #6b7280; font-size: 0.65rem; min-width: 5.5rem; flex-shrink: 0; text-align: right; }
.tng-ti-last-trade { font-size: 0.68rem; color: #4b5563; margin-top: 0.25rem; }

/* Legend sits inline inside .tng-ti-section-title (flex set on the rule above) */
.tng-ti-yr-legend {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.6rem;
    color: #4b5563;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    margin-left: auto;
    flex-shrink: 0;
}
.tng-ti-yr-legend-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 2px;
    flex-shrink: 0;
}
.tng-ti-yr-legend-league { background: #0ea5e9; }
.tng-ti-yr-legend-own    { background: #7c3aed; }

/* "Open Jerry's Thoughts" link-style button */
.tng-ti-intel-btn {
    background: none;
    border: none;
    color: #818cf8;
    font-size: 0.72rem;
    cursor: pointer;
    padding: 0.15rem 0;
    text-align: left;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.tng-ti-intel-btn:hover { color: #a5b4fc; }

/* Footer note */
.tng-ti-footer {
    font-size: 0.7rem;
    color: #4b5563;
    padding: 0.6rem 0 0.2rem;
    text-align: center;
    flex-shrink: 0;
}

/* ── Expired contract footnote chip on grid cells ───────────────────────── */
/* Small inline note below the % value when expired players were excluded   */
.tng-expired-note {
    /* inline so it sits right of the % number without pushing rows taller */
    display: inline;
    font-size: 0.55rem;
    color: #f59e0b;
    margin-left: 3px;
    cursor: help;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

/* ── Trade Intel tab: loading spinner state ─────────────────────────────── */
.tng-ti-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 3rem 2rem;
    color: #6b7280;
}
.tng-ti-loading-text {
    font-size: 0.82rem;
    color: #9ca3af;
}