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

:root {
    /* Bitjita-style dark theme - slate/zinc palette */
    --bg-primary: #09090b;
    --bg-secondary: #18181b;
    --bg-card: #27272a;
    --bg-hover: #3f3f46;
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --success: #22c55e;
    --warning: #eab308;
    --danger: #ef4444;
    --border: #3f3f46;
    --border-subtle: #27272a;

    /* Rarity colors - WoW-style */
    --rarity-common: #9ca3af;
    --rarity-uncommon: #22c55e;
    --rarity-rare: #3b82f6;
    --rarity-epic: #a855f7;
    --rarity-legendary: #f97316;
    --rarity-mythic: #eab308;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.4;
    font-size: 13px;
}

html {
    scroll-behavior: smooth;
}

/* Header */
header {
    background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

header h1 {
    font-size: 1.125rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 50%, #a78bfa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-nav {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
    letter-spacing: 0.01em;
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.nav-link.active {
    color: var(--accent);
    background: rgba(59, 130, 246, 0.1);
}

/* Main content */
main {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0.75rem;
}

section {
    background: var(--bg-secondary);
    padding: 0.875rem;
    border-radius: 12px;
    margin-bottom: 0.75rem;
    border: 1px solid var(--border-subtle);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

section h2 {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Player Management */
.player-management {
    background: var(--bg-secondary);
    padding: 0.625rem 0.875rem;
    border-radius: 12px;
    margin-bottom: 0.75rem;
    border: 1px solid var(--border-subtle);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.player-search-inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.player-search-inline label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    min-width: 80px;
}

.player-search-inline input {
    flex: 1;
    padding: 0.375rem 0.625rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.75rem;
    transition: all 0.2s;
}

.player-search-inline input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.player-search-inline button {
    padding: 0.375rem 0.875rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.player-search-inline button:hover {
    background: var(--accent-hover);
}

.active-players-inline {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.active-players-inline label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    min-width: 80px;
    padding-top: 0.25rem;
}

.active-players-inline .player-chips {
    flex: 1;
}

/* Player Search */
.search-box {
    display: flex;
    gap: 0.5rem;
}

.search-box input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.8125rem;
    transition: all 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

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

.search-box button {
    padding: 0.5rem 1rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.8125rem;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.search-box button:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

.search-box button:active {
    transform: translateY(0);
}

.search-results {
    margin-top: 0.5rem;
}

.search-result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: var(--bg-card);
    border-radius: 8px;
    margin-bottom: 0.375rem;
    font-size: 0.8125rem;
    border: 1px solid var(--border-subtle);
    transition: all 0.2s;
}

.search-result-item:hover {
    border-color: var(--border);
    transform: translateX(4px);
}

.search-result-item button {
    padding: 0.375rem 0.75rem;
    background: var(--success);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.search-result-item button:hover {
    background: #16a34a;
    transform: scale(1.05);
}

/* Player Chips */
.player-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.player-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-hover) 100%);
    border-radius: 9999px;
    font-size: 0.75rem;
    border: 1px solid var(--border);
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.player-chip:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    border-color: var(--accent);
}

.player-chip .remove-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-chip .remove-btn:hover {
    color: var(--danger);
    transform: scale(1.2);
}

/* View Controls */
.controls-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.625rem;
}

.stats-inline {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.stat-inline {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.125rem;
}

.stat-inline .stat-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

.stat-inline .stat-label {
    font-size: 0.625rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

.controls-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: flex-end;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.control-group label {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-muted);
}

.control-group select,
.control-group input[type="text"] {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.75rem;
    min-width: 110px;
    transition: all 0.2s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.control-group select:focus,
.control-group input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.control-group select:hover,
.control-group input[type="text"]:hover {
    border-color: var(--text-muted);
}

.control-group input[type="text"]::placeholder {
    color: var(--text-muted);
}

.checkbox-group {
    flex-direction: row;
    align-items: center;
    padding-bottom: 0.2rem;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--text-primary);
    font-weight: normal;
}

.checkbox-group input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: var(--accent);
}

/* Market Controls */
.market-controls {
    background: var(--bg-secondary);
    padding: 0.875rem;
    border-radius: 12px;
    margin-bottom: 0.75rem;
    border: 1px solid var(--border-subtle);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.market-controls h2 {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Tag Filter Container */
.tag-filter-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0.4rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    max-height: 120px;
    overflow-y: auto;
}

.tag-filter-item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.45rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.6875rem;
    transition: all 0.2s;
    user-select: none;
    line-height: 1.2;
}

.tag-filter-item:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.tag-filter-item input[type="checkbox"] {
    width: 12px;
    height: 12px;
    cursor: pointer;
    accent-color: var(--accent);
    margin: 0;
}

.tag-filter-item span {
    color: var(--text-primary);
}

/* Stats Bar */
.stats-bar {
    display: flex;
    justify-content: center;
    gap: 2rem;
    padding: 0.75rem 0.5rem !important;
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-secondary) 100%);
}

.stats-bar .stat {
    text-align: center;
    position: relative;
    padding: 0.25rem 0.75rem;
}

.stats-bar .stat::after {
    content: '';
    position: absolute;
    right: -1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1px;
    height: 1.5rem;
    background: var(--border);
}

.stats-bar .stat:last-child::after {
    display: none;
}

.stats-bar .stat-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.stats-bar .stat-label {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.125rem;
}

/* Inventory Display */
.inventory-display {
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
}

#inventory-content {
    background: transparent;
    border-radius: 12px;
    overflow: visible;
}

.inventory-group {
    background: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    margin-bottom: 0.75rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.inventory-group:last-child {
    margin-bottom: 0;
}

.group-header {
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-hover) 100%);
    padding: 0.625rem 0.875rem;
    font-weight: 600;
    font-size: 0.8125rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.group-header:hover {
    background: var(--bg-hover);
}

.group-header:active {
    transform: scale(0.99);
}

.group-header-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.group-chevron {
    font-size: 0.6875rem;
    color: var(--accent);
    transition: transform 0.3s ease;
    display: inline-block;
}

.group-name {
    font-size: 0.8125rem;
}

.group-header .group-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: normal;
    background: var(--bg-primary);
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-subtle);
}

.group-content {
    max-height: 10000px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 1;
}

.group-content.collapsed {
    max-height: 0;
    opacity: 0;
}

/* Inventory Table */
.inventory-table {
    width: 100%;
    border-collapse: collapse;
}

.inventory-table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    background: var(--bg-card);
    font-weight: 600;
    font-size: 0.6875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.inventory-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.8125rem;
    vertical-align: top;
    line-height: 1.6;
}

.inventory-table tbody tr:last-child td {
    border-bottom: none;
}

.inventory-table tbody tr:hover td {
    background: var(--bg-hover) !important;
}

/* When no grouping, add rounded corners to standalone table */
.inventory-display > #inventory-content > .inventory-table {
    background: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.item-name {
    font-weight: 500;
}

.tier-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
    font-size: 0.6875rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--bg-hover) 0%, var(--bg-card) 100%);
    color: var(--text-primary);
    min-width: 36px;
    text-align: center;
    border: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Rarity badge styling - colored pill badges */
.inventory-table td .rarity-common,
.inventory-table td .rarity-uncommon,
.inventory-table td .rarity-rare,
.inventory-table td .rarity-epic,
.inventory-table td .rarity-legendary,
.inventory-table td .rarity-mythic {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 600;
    border: 1px solid transparent;
    white-space: nowrap;
    color: white;
}

.inventory-table td .rarity-common {
    background: var(--rarity-common);
    color: var(--bg-primary);
}

.inventory-table td .rarity-uncommon {
    background: var(--rarity-uncommon);
}

.inventory-table td .rarity-rare {
    background: var(--rarity-rare);
}

.inventory-table td .rarity-epic {
    background: var(--rarity-epic);
}

.inventory-table td .rarity-legendary {
    background: var(--rarity-legendary);
}

.inventory-table td .rarity-mythic {
    background: var(--rarity-mythic);
    color: var(--bg-primary);
}

/* Rarity styling for table rows */
.inventory-table tbody tr {
    transition: all 0.15s;
}

/* Apply colored border to first cell of each row */
.inventory-table tbody tr.rarity-row-common td:first-child {
    border-left: 3px solid var(--rarity-common);
}

.inventory-table tbody tr.rarity-row-uncommon {
    background: rgba(34, 197, 94, 0.03);
}

.inventory-table tbody tr.rarity-row-uncommon td:first-child {
    border-left: 3px solid var(--rarity-uncommon);
}

.inventory-table tbody tr.rarity-row-rare {
    background: rgba(59, 130, 246, 0.03);
}

.inventory-table tbody tr.rarity-row-rare td:first-child {
    border-left: 3px solid var(--rarity-rare);
}

.inventory-table tbody tr.rarity-row-epic {
    background: rgba(168, 85, 247, 0.03);
}

.inventory-table tbody tr.rarity-row-epic td:first-child {
    border-left: 3px solid var(--rarity-epic);
}

.inventory-table tbody tr.rarity-row-legendary {
    background: rgba(249, 115, 22, 0.03);
}

.inventory-table tbody tr.rarity-row-legendary td:first-child {
    border-left: 3px solid var(--rarity-legendary);
}

.inventory-table tbody tr.rarity-row-mythic {
    background: rgba(234, 179, 8, 0.03);
}

.inventory-table tbody tr.rarity-row-mythic td:first-child {
    border-left: 3px solid var(--rarity-mythic);
}

.inventory-table tbody tr:hover {
    background: var(--bg-hover) !important;
}

.count-value {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

.price-value {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--accent);
}

.loading-text {
    color: var(--text-muted);
    font-style: italic;
    font-weight: 400;
    font-size: 0.75rem;
}

.player-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    align-items: flex-start;
    line-height: 1.6;
}

.player-tag {
    font-size: 0.6875rem;
    color: var(--text-muted);
    background: var(--bg-hover);
    padding: 0.1rem 0.375rem;
    border-radius: 4px;
    white-space: nowrap;
}

/* Footer */
footer {
    background: var(--bg-secondary);
    padding: 0.875rem;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.2);
}

footer button {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

footer button:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

footer button:active {
    transform: translateY(0);
}

#clear-btn:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.3);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(9, 9, 11, 0.95);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    z-index: 1000;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    opacity: 1;
    transition: opacity 0.3s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-right-color: var(--accent-hover);
    border-radius: 50%;
    animation: spin 0.8s cubic-bezier(0.68, -0.55, 0.27, 1.55) infinite;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
}

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

/* Empty State */
.empty-state {
    padding: 2rem 1.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8125rem;
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-secondary) 100%);
    border-radius: 8px;
    border: 2px dashed var(--border);
}

/* Error State */
.error-message {
    color: var(--danger);
    padding: 0.75rem 1rem;
    text-align: center;
    font-size: 0.8125rem;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 8px;
    border: 1px solid var(--danger);
}

/* Responsive */
@media (max-width: 768px) {
    main {
        padding: 0.5rem;
    }

    section {
        padding: 0.75rem;
    }

    .controls-row {
        flex-direction: column;
        align-items: stretch;
    }

    .control-group {
        width: 100%;
    }

    .control-group select,
    .control-group input[type="text"] {
        width: 100%;
    }

    .stats-bar {
        gap: 1rem;
    }

    .inventory-table th:nth-child(4),
    .inventory-table td:nth-child(4) {
        display: none;
    }

    header {
        padding: 0.75rem 1rem;
    }

    header h1 {
        font-size: 1.25rem;
    }
}
