body {
    padding-top: 20px;
    background-color: #d8e1eb;
    font-size: 0.85rem;
    transition: background-color 0.2s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.table-hover tbody tr.item-row {
    cursor: pointer;
    transition: background-color 0.2s;
}

.profit-pos {
    color: #198754;
    font-weight: bold;
}

.profit-neg {
    color: #dc3545;
    font-weight: bold;
}

/* Brighter colors in dark mode for better visibility */
[data-bs-theme="dark"] .profit-pos {
    color: #00e676;
}

[data-bs-theme="dark"] .profit-neg {
    color: #ff5252;
}

/* Table Data - Improved Legibility */
.table {
    font-size: 0.8rem;
}

.table td {
    font-family: sans-serif;
    font-variant-numeric: tabular-nums;
    vertical-align: middle;
    letter-spacing: 0.01em;
}

.table th {
    font-size: 0.75rem;
}

/* Passive Trading Guide Popover */
.passive-guide-popover {
    max-width: 320px;
}

.passive-guide-popover .popover-body {
    padding: 10px;
}

.passive-guide-content hr {
    border-color: rgba(255, 255, 255, 0.2);
}

/* Item name hover for popover */
.item-name {
    border-bottom: 1px dotted currentColor;
    cursor: help;
    transition: color 0.15s ease;
}

.item-name:hover {
    color: #0d6efd;
}

[data-bs-theme="dark"] .item-name:hover {
    color: #42a5f5;
}

/* Item Info Card Popover */
.item-info-popover {
    max-width: 280px;
    font-size: 0.85rem;
}

.item-info-popover .popover-body {
    padding: 12px;
}

.item-info-card hr {
    border-color: rgba(128, 128, 128, 0.3);
    margin: 8px 0;
}

.item-info-card .info-row {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
}

/* Hoverable item link in crafting/news */
.item-link-hover {
    cursor: pointer;
    border-bottom: 1px dotted currentColor;
    transition: color 0.15s;
}

.item-link-hover:hover {
    color: var(--bs-primary);
}

.detail-row {
    display: none;
    background-color: rgba(var(--bs-body-bg-rgb), 0.05);
}

.detail-row.show {
    display: table-row;
}

/* CSP-compliant utility classes (replacing inline styles) */
.item-icon {
    width: 24px;
    height: 24px;
    margin-right: 8px;
    vertical-align: middle;
}

.sparkline-cell {
    width: 120px;
    vertical-align: middle;
}

.sparkline-canvas {
    width: 100px;
    height: 24px;
    display: block;
    margin: 0 auto;
}

.cursor-pointer {
    cursor: pointer;
}

.info-icon {
    font-size: 0.7em;
}

.section-header {
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.price-chart-container {
    height: 250px;
    min-height: 250px;
    display: block;
    position: relative;
}

.volume-chart-container {
    height: 120px;
    min-height: 120px;
    display: block;
    position: relative;
}

.crafting-scroll {
    max-height: 150px;
    overflow-y: auto;
}

.premium-border {
    border-color: rgba(255, 193, 7, 0.3) !important;
}

.premium-header {
    background-color: rgba(255, 193, 7, 0.08);
}

.premium-icon {
    font-size: 1em;
    color: rgba(255, 193, 7, 0.6);
}

.premium-gem {
    font-size: 1.1em;
    color: rgba(255, 193, 7, 0.5);
}

.passive-guide-small {
    font-size: 0.75rem;
}

.header-nav {
    margin-top: -20px;
}

.theme-dropdown {
    min-width: 120px;
}

/* Mobile header layout */
.mobile-header-column {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.mobile-logo {
    max-height: 60px;
    max-width: 75vw;
    width: auto;
    display: block;
}

.test-badge {
    display: none;
    font-size: 0.65em;
    letter-spacing: 0.5px;
    margin-left: 2px;
}

.test-badge-mobile {
    display: none;
    font-size: 0.6rem;
    vertical-align: middle;
}

/* Filter dropdowns */
.filter-dropdown-min {
    min-width: 120px;
}

.col-menu-dropdown {
    min-width: 200px;
}

.limit-dropdown {
    min-width: 100px;
}

.container-tight {
    padding-left: 8px;
    padding-right: 8px;
}

.overflow-x-hidden {
    overflow-x: hidden;
}

/* Filter select widths */
.filter-select-wide {
    max-width: 85px;
}

.filter-select {
    max-width: 70px;
}

/* Premium star icons */
.premium-star-sm {
    font-size: 0.7em;
}

.premium-star-md {
    font-size: 0.8em;
}

/* News item styles */
.news-flex-item {
    min-width: 0;
    flex: 1;
}

.news-link {
    line-height: 1.2;
}

.news-title {
    font-size: 0.85rem;
    max-width: 75%;
}

.news-icon {
    width: 14px;
    height: 14px;
    margin-right: 4px;
    vertical-align: text-bottom;
}

.news-date {
    font-size: 0.7rem;
}

.news-source {
    font-size: 0.7rem;
}

/* Width utilities */
.w-auto {
    width: auto !important;
}

.w-60px {
    width: 60px;
}

/* Premium trading guide styles */
.premium-gold-star {
    color: #ffc107;
}

.guide-icon-lg {
    font-size: 1.5rem;
}

.premium-lock-icon {
    font-size: 1.2rem;
}

/* Price value styles by confidence */
.guide-price-high {
    font-size: 1.4rem;
}

.guide-price-medium {
    font-size: 1.2rem;
}

.guide-price-low {
    font-size: 1rem;
}

.guide-price-green {
    color: var(--green);
}

.guide-price-red {
    color: var(--red);
}

/* AFK score display */
.afk-score-value {
    font-size: 0.75rem;
}

/* Progress bar colors */
.progress-bar-green {
    background: var(--green);
}

.progress-bar-yellow {
    background: var(--yellow);
}

.progress-bar-muted {
    background: var(--text-muted);
}

/* Calculator form styles */
.calc-label {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.calc-input {
    font-size: 0.8rem;
}

/* Chart container heights */
.chart-height-280 {
    height: 280px;
}

.volume-chart-height {
    height: 100px;
    border-top: 1px solid var(--bs-border-color);
}

.chart-container {
    position: relative;
    height: 350px;
    width: 100%;
}

/* Table horizontal scroll only - no inner vertical scroll */
.table-scroll-container {
    overflow-x: auto !important;
    overflow-y: visible;
    position: relative;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

/* Ensure parent containers don't break sticky, but not the scroll container */
.card {
    overflow: visible !important;
}
.card-body:not(.table-scroll-container) {
    overflow: visible !important;
}

/* Table Grid Styling */
.table {
    border-collapse: separate;
    border-spacing: 0;
}

.table thead th {
    font-weight: 600;
    letter-spacing: 0.02em;
    border-bottom: 2px solid;
}

/* Fixed header clone for cross-browser sticky support */
.fixed-header-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: none;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.fixed-header-wrapper.visible {
    display: block;
}

.fixed-header-wrapper table {
    margin-bottom: 0;
}

.fixed-header-wrapper th {
    font-weight: 600;
    letter-spacing: 0.02em;
    border-bottom: 2px solid;
    background-color: #c8d4e3;
    color: #1e293b;
    border-bottom-color: #94a3b8;
}

[data-bs-theme="dark"] .fixed-header-wrapper {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
}

[data-bs-theme="dark"] .fixed-header-wrapper th {
    background-color: #0a0a0a !important;
    color: #e8e8e8 !important;
    border-bottom-color: #1a1a1a !important;
}

[data-bs-theme="dark"] .fixed-header-wrapper .card {
    background-color: #0a0a0a;
    border-color: #1a1a1a;
}

/* Mobile fixed header adjustments */
@media (max-width: 768px) {
    .fixed-header-wrapper .container-fluid {
        padding-left: 8px;
        padding-right: 8px;
    }
    .fixed-header-wrapper .card {
        border-radius: 0;
        margin: 0;
    }
    .fixed-header-wrapper th {
        font-size: 0.75rem;
        padding: 0.4rem 0.3rem;
    }
}

@media (max-width: 576px) {
    .fixed-header-wrapper .container-fluid {
        padding-left: 4px;
        padding-right: 4px;
    }
    .fixed-header-wrapper th {
        font-size: 0.7rem;
        padding: 0.35rem 0.2rem;
    }
}

/* Light mode table header */
.table thead th {
    background-color: #c8d4e3;
    color: #1e293b;
    border-bottom-color: #94a3b8;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

/* Dark mode table header */
[data-bs-theme="dark"] .table thead th {
    background-color: #0a0a0a !important;
    color: #e8e8e8 !important;
    border-bottom-color: #1a1a1a !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

/* Table body borders */
.table td {
    border-bottom: 1px solid #d1dae6;
}

[data-bs-theme="dark"] .table td {
    border-bottom-color: #1a1a1a;
}

/* Scroll shadow indicators for horizontal scroll */
.table-scroll-container::before,
.table-scroll-container::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 20px;
    pointer-events: none;
    z-index: 5;
    opacity: 0;
    transition: opacity 0.3s;
}

.table-scroll-container::before {
    left: 0;
    background: linear-gradient(to right, rgba(0, 0, 0, 0.1), transparent);
}

.table-scroll-container::after {
    right: 0;
    background: linear-gradient(to left, rgba(0, 0, 0, 0.1), transparent);
}

.table-scroll-container.scrolled-left::before {
    opacity: 1;
}

.table-scroll-container.scrolled-right::after {
    opacity: 1;
}

/* Dark mode scroll shadows - more visible */
[data-bs-theme="dark"] .table-scroll-container::before {
    background: linear-gradient(to right, rgba(0, 0, 0, 0.4), transparent);
}

[data-bs-theme="dark"] .table-scroll-container::after {
    background: linear-gradient(to left, rgba(0, 0, 0, 0.4), transparent);
}

/* Mobile Optimizations - App-like feel */
@media (max-width: 768px) {
    body {
        padding-top: 0;
        padding-bottom: env(safe-area-inset-bottom, 20px);
        -webkit-tap-highlight-color: transparent;
        font-size: 0.88rem;
    }

    .container-fluid {
        padding-left: 8px;
        padding-right: 8px;
    }

    /* Mobile App Header */
    .mobile-app-header {
        display: flex;
        align-items: center;
        padding: 12px 8px;
        gap: 10px;
    }

    .mobile-app-logo {
        width: 36px;
        height: 36px;
        border-radius: 8px;
    }

    .mobile-app-title {
        font-size: 1.1rem;
        font-weight: 600;
        flex: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mobile-header-actions {
        display: flex;
        gap: 4px;
        align-items: center;
    }

    .mobile-icon-btn {
        width: 44px;
        height: 44px;
        border-radius: 22px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        color: var(--bs-body-color);
        font-size: 1.2rem;
        transition: background-color 0.15s ease;
    }

    .mobile-icon-btn:active {
        background-color: rgba(128, 128, 128, 0.2);
        transform: scale(0.95);
    }

    /* Settings dropdown for mobile */
    .mobile-settings-dropdown {
        min-width: 200px;
    }

    .mobile-settings-dropdown .dropdown-header {
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: var(--bs-secondary-color);
        padding: 8px 16px 4px;
    }

    .mobile-settings-dropdown .dropdown-item {
        padding: 12px 16px;
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .mobile-settings-dropdown .dropdown-item i {
        width: 20px;
        text-align: center;
    }

    /* Mobile auth wrapper - compact avatar-only style */
    .mobile-auth-wrapper {
        display: flex;
        align-items: center;
    }

    .mobile-auth-wrapper .dropdown {
        margin-bottom: 0 !important;
    }

    .mobile-auth-wrapper .dropdown-toggle {
        padding: 0;
        display: flex;
        align-items: center;
    }

    /* Hide username on mobile, show only avatar */
    .mobile-auth-wrapper .d-none.d-sm-inline,
    .mobile-auth-wrapper span.small {
        display: none !important;
    }

    .mobile-auth-wrapper img {
        width: 32px !important;
        height: 32px !important;
        margin-right: 0 !important;
    }

    /* Sign in button compact on mobile */
    .mobile-auth-wrapper .btn {
        padding: 8px 12px;
        margin-bottom: 0 !important;
        font-size: 0.85rem;
    }

    /* Desktop controls show on desktop (wrapper is d-none d-md-flex) */

    /* App-like header spacing */
    .card {
        border-radius: 12px;
        margin-bottom: 12px;
    }

    /* Remove card borders on mobile for cleaner look */
    [data-bs-theme="dark"] .card {
        border: none;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
    }

    /* Hide less critical columns on small mobile */
    .col-mobile-hide {
        display: none !important;
    }

    /* Slightly larger text for better readability */
    .table {
        font-size: 0.82rem;
    }

    .table td,
    .table th {
        padding: 0.5rem 0.35rem;
    }

    /* Adjust sparkline size for mobile */
    .sparkline {
        width: 50px !important;
    }

    /* Make action buttons larger targets (48px min touch target) */
    .btn-sm {
        padding: 0.5rem 0.7rem;
        font-size: 0.8rem;
        min-height: 44px;
        min-width: 44px;
        border-radius: 8px;
    }

    .action-btn {
        font-size: 1.3em;
        padding: 4px;
        min-width: 40px;
        min-height: 40px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px;
        transition: transform 0.1s ease, background-color 0.15s ease;
    }

    .action-btn:active {
        transform: scale(0.92);
        background-color: rgba(128, 128, 128, 0.15);
    }

    /* Ensure detail row doesn't break layout */
    .detail-row td {
        padding: 0 !important;
    }

    .detail-row .position-relative {
        min-height: 320px !important;
    }

    /* Pagination mobile-friendly */
    .pagination {
        flex-wrap: nowrap;
        justify-content: center;
        gap: 6px;
    }

    .pagination .page-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
        min-height: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 22px;
        font-weight: 500;
    }

    /* Active page - more prominent */
    .pagination .page-item.active .page-link {
        font-weight: 700;
        transform: scale(1.1);
        box-shadow: 0 2px 8px rgba(13, 110, 253, 0.4);
    }

    /* Ellipsis styling */
    .pagination .page-item.disabled .page-link {
        min-width: 32px;
        padding: 0.5rem 0.3rem;
    }

    /* Items per page selector */
    .form-select.form-select-sm {
        min-height: 44px;
        font-size: 0.85rem;
        border-radius: 8px;
    }

    /* Search input touch-friendly */
    .form-control {
        min-height: 44px;
        border-radius: 8px;
    }

    /* Table rows - app-like touch feedback */
    .table-hover tbody tr.item-row:active {
        background-color: rgba(13, 110, 253, 0.15) !important;
    }
}

/* Portrait Mobile Optimizations (iPhone) - Full app experience */
@media (max-width: 576px) {
    .container-fluid {
        padding-left: 4px;
        padding-right: 4px;
    }

    .card {
        border-radius: 16px;
        border: none;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }

    [data-bs-theme="dark"] .card {
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
    }

    .col-portrait-hide {
        display: none !important;
    }

    /* Mobile detail row improvements */
    .detail-row > td {
        padding: 0 !important;
    }

    .detail-row .p-3 {
        padding: 0.75rem !important;
    }

    .detail-row .card-header {
        padding: 0.5rem !important;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .detail-row .btn-group {
        flex-wrap: wrap;
    }

    .detail-row .btn-xs {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }

    /* Stats blocks - reduce padding */
    .detail-row .row > div {
        padding: 0.5rem !important;
    }

    .detail-row .text-uppercase {
        font-size: 0.65rem !important;
    }

    .table td,
    .table th {
        padding: 0.5rem 0.2rem;
    }

    .table {
        font-size: 0.78rem;
    }

    /* Mobile Column Width Optimization */
    /* Item column (first) - wider to show name properly */
    #mainTable th:first-child,
    #mainTable td:first-child {
        min-width: 120px;
        max-width: 150px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* CE column - compact */
    .col-orig-13,
    #mainTable th:nth-last-child(1),
    #mainTable th:nth-last-child(2),
    #mainTable td:nth-last-child(1),
    #mainTable td:nth-last-child(2) {
        min-width: 40px;
        max-width: 50px;
        padding: 0.3rem 0.15rem;
    }

    /* Profit column - moderate width */
    .col-orig-7 {
        min-width: 60px;
        max-width: 80px;
    }

    /* Compact action buttons for portrait */
    .action-btn {
        font-size: 1em;
        padding: 1px;
    }

    /* Truncate Item Name to fit */
    .col-orig-0 {
        max-width: 100px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

}

/* Very Small Screens (iPhone SE, small Android phones < 400px) */
@media (max-width: 400px) {
    body {
        font-size: 0.8rem;
    }

    .container-fluid {
        padding-left: 2px;
        padding-right: 2px;
    }

    .table {
        font-size: 0.72rem;
    }

    .table td,
    .table th {
        padding: 0.4rem 0.1rem;
    }

    /* Filter dropdown - shrink for tiny screens */
    .dropdown-menu-filter {
        min-width: 220px;
        max-width: calc(100vw - 20px);
    }

    /* Item column even more compact */
    #mainTable th:first-child,
    #mainTable td:first-child {
        min-width: 90px;
        max-width: 110px;
    }

    /* Reduce detail row height */
    .detail-row .position-relative {
        min-height: 280px !important;
    }

    .chart-container {
        height: 280px;
    }

    /* Pagination - super compact on small phones */
    .pagination {
        gap: 3px;
    }

    .pagination .page-link {
        padding: 0.4rem 0.55rem;
        font-size: 0.8rem;
        min-height: 38px;
        min-width: 38px;
        border-radius: 19px;
    }

    /* Hide ellipsis on small screens */
    .pagination .page-ellipsis {
        display: none !important;
    }

    /* Hide page 1 and last page when not near them */
    .pagination .page-item:not(.active):not(:first-child):not(:last-child) {
        /* Keep visible but can be hidden via JS if needed */
    }

    /* Mobile Infinite Scroll - hide pagination and controls when enabled */
    body.infinite-scroll-enabled .controls-right,
    body.infinite-scroll-enabled .controls-left {
        display: none !important;
    }

    body.infinite-scroll-enabled .controls-center {
        flex: 1;
        justify-content: center;
    }

    /* Show infinite scroll loader only on mobile when enabled */
    body.infinite-scroll-enabled .infinite-scroll-loader {
        display: block;
    }

    /* Auth block compact */
    .dropdown-toggle img {
        width: 20px !important;
        height: 20px !important;
    }
}

/* Infinite scroll loader - hidden by default on all screen sizes */
.infinite-scroll-loader {
    display: none;
    text-align: center;
    padding: 1rem;
}

.load-more-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--bs-body-color);
    background: var(--bs-tertiary-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 20px;
    cursor: pointer;
    min-width: 140px;
    min-height: 44px;
    transition: all 0.15s ease;
}

.load-more-btn:hover {
    background: var(--bs-secondary-bg);
}

.load-more-btn:active {
    transform: scale(0.96);
}

.load-more-btn .spinner-border {
    display: none;
    width: 1rem;
    height: 1rem;
}

.infinite-scroll-loader.loading .load-more-btn .spinner-border {
    display: inline-block;
}

.infinite-scroll-loader.loading .load-more-btn .load-more-label {
    display: none;
}

.infinite-scroll-loader.all-loaded .load-more-btn {
    display: none;
}

.all-loaded-text {
    display: none;
    color: var(--bs-secondary-color);
    font-size: 0.8rem;
}

.infinite-scroll-loader.all-loaded .all-loaded-text {
    display: inline;
}

[data-bs-theme="dark"] .load-more-btn {
    background: #0a0a0a;
    border-color: #2a2a2a;
}

[data-bs-theme="dark"] .load-more-btn:hover {
    background: #151515;
}

/* Header styling for filter dropdowns */
th {
    user-select: none;
    position: relative;
    padding-right: 20px;
    cursor: help;
    transition: background-color 0.15s ease;
}

/* Base th:hover uses CSS variables for browser compatibility */
th:hover {
    background-color: var(--bs-secondary-bg) !important;
    color: var(--bs-body-color);
}

/* Light mode override */
[data-bs-theme="light"] th:hover {
    background-color: #b8c7d9 !important;
    color: #1e293b;
}

/* Dark mode override */
[data-bs-theme="dark"] th:hover {
    background-color: #151515 !important;
    color: #fff;
}

.filter-icon {
    cursor: pointer;
    font-size: 0.8em;
    margin-left: 5px;
    opacity: 0.5;
    color: var(--bs-body-color);
}

.filter-icon:hover {
    opacity: 1;
}

.dropdown-menu-filter {
    padding: 10px;
    min-width: 280px;
    max-width: calc(100vw - 30px);
}

/* Mobile filter dropdown improvements */
@media (max-width: 576px) {
    .dropdown-menu-filter {
        min-width: 240px;
        padding: 8px;
    }

    .dropdown-menu-filter .form-select,
    .dropdown-menu-filter .form-control {
        font-size: 0.85rem;
        padding: 0.4rem 0.6rem;
    }

    .dropdown-menu-filter .btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.85rem;
    }
}

/* Action Buttons */
.action-btn {
    cursor: pointer;
    opacity: 0.3;
    font-size: 1.5em;
    transition: all 0.2s;
}

.action-btn:hover {
    opacity: 1;
    transform: scale(1.15);
}

/* Favorites */
.fav-btn.active {
    color: #ffc107;
    opacity: 1;
    text-shadow: 0 0 5px #ffc107;
}

.detail-row .detail-fav-btn.active,
button.detail-fav-btn.active,
.detail-fav-btn.btn-warning {
    background-color: #ffc107 !important;
    border-color: #ffc107 !important;
    color: #000 !important;
}

.detail-row .detail-fav-btn.active i::before,
button.detail-fav-btn.active i::before,
.detail-fav-btn.btn-warning i::before {
    content: "\F586"; /* bi-star-fill */
}

tr.row-fav {
    border-left: 5px solid #198754;
}

/* Force background color with high specificity */
table.table tbody tr.row-fav > td {
    background-color: rgba(25, 135, 84, 0.15) !important;
    --bs-table-accent-bg: rgba(25, 135, 84, 0.15) !important;
}

[data-bs-theme="dark"] table.table tbody tr.row-fav > td {
    background-color: rgba(25, 135, 84, 0.3) !important;
    --bs-table-accent-bg: rgba(25, 135, 84, 0.3) !important;
}

/* Hidden */
.hide-btn.active {
    color: #dc3545;
    opacity: 1;
    text-shadow: 0 0 5px #dc3545;
}

.detail-row .detail-hide-btn.active,
button.detail-hide-btn.active,
.detail-hide-btn.btn-danger {
    background-color: #dc3545 !important;
    border-color: #dc3545 !important;
    color: #fff !important;
}

tr.row-hide {
    border-left: 5px solid #dc3545;
    opacity: 0.6;
}

table.table tbody tr.row-hide > td {
    background-color: rgba(220, 53, 69, 0.15) !important;
    --bs-table-accent-bg: rgba(220, 53, 69, 0.15) !important;
}

[data-bs-theme="dark"] table.table tbody tr.row-hide > td {
    background-color: rgba(220, 53, 69, 0.3) !important;
    --bs-table-accent-bg: rgba(220, 53, 69, 0.3) !important;
}

/* Draggable Columns */
th[draggable="true"] {
    cursor: grab;
}

th[draggable="true"]:active {
    cursor: grabbing;
}

th.drag-over {
    border-left: 2px solid #0d6efd;
}

/* Column Resizing */
th {
    position: relative;
}

.resizer {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    width: 5px;
    background: rgba(0, 0, 0, 0.1);
    cursor: col-resize;
    user-select: none;
    transition: background 0.2s;
}

.resizer:hover,
.resizing .resizer {
    background: #0d6efd;
    width: 2px;
}

.resizing {
    cursor: col-resize;
}

/* True Black OLED Dark Mode */
[data-bs-theme="dark"] body {
    background-color: #000000 !important;
    color: #e8e8e8 !important;
}

[data-bs-theme="dark"] .card {
    background-color: #0a0a0a !important;
    border: 1px solid #1a1a1a;
}

[data-bs-theme="dark"] .bg-body-tertiary {
    background-color: #0a0a0a !important;
    border-bottom: 1px solid #1a1a1a !important;
}

[data-bs-theme="dark"] .table {
    --bs-table-bg: #0a0a0a;
    --bs-table-color: #e8e8e8;
    border-color: #1a1a1a;
}

[data-bs-theme="dark"] .table-striped>tbody>tr:nth-of-type(odd)>* {
    --bs-table-accent-bg: #111111;
    color: #e8e8e8;
}

[data-bs-theme="dark"] .table-hover>tbody>tr:hover>* {
    --bs-table-accent-bg: #1a1a1a;
    color: #ffffff;
}

[data-bs-theme="dark"] .detail-row {
    background-color: #050505 !important;
}

[data-bs-theme="dark"] th {
    background-color: #0a0a0a !important;
    border-color: #1a1a1a !important;
    color: #e8e8e8 !important;
}

[data-bs-theme="dark"] .btn-outline-secondary {
    color: #b0b0b0;
    border-color: #2a2a2a;
}

[data-bs-theme="dark"] .btn-outline-secondary:hover {
    background-color: #1a1a1a;
    color: #fff;
}

/* Pagination Theme Consistency */
[data-bs-theme="dark"] .pagination .page-link {
    background-color: #0a0a0a;
    border-color: #1a1a1a;
    color: #e8e8e8;
}

[data-bs-theme="dark"] .pagination .page-link:hover {
    background-color: #1a1a1a;
    border-color: #2a2a2a;
    color: #fff;
}

[data-bs-theme="dark"] .pagination .page-item.active .page-link {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: #fff;
    box-shadow: 0 2px 8px rgba(13, 110, 253, 0.5);
}

[data-bs-theme="dark"] .pagination .page-item.disabled .page-link {
    background-color: #050505;
    border-color: #1a1a1a;
    color: #444;
}

/* Light mode - Darker blue-gray tint for softer appearance */
[data-bs-theme="light"] body {
    background-color: #d8e1eb !important;
}

[data-bs-theme="light"] .card {
    background-color: #f0f4f8;
    border: 1px solid #c5d1de;
    box-shadow: 0 1px 3px rgba(100, 116, 139, 0.12);
}

[data-bs-theme="light"] .table {
    --bs-table-bg: #f0f4f8;
}

[data-bs-theme="light"] .table-striped>tbody>tr:nth-of-type(odd)>* {
    --bs-table-accent-bg: #e8f0f8;
}

[data-bs-theme="light"] .table-hover>tbody>tr:hover>* {
    --bs-table-accent-bg: #dde6f0;
}

[data-bs-theme="light"] th {
    background-color: #c8d4e3 !important;
    border-color: #94a3b8;
}

[data-bs-theme="light"] .btn-outline-secondary {
    border-color: #a8b8c8;
}

[data-bs-theme="light"] .btn-outline-secondary:hover {
    background-color: #dde6f0;
}

/* Light mode pagination (subtle styling) */
.pagination .page-link {
    background-color: #f0f4f8;
    border-color: #c5d1de;
    color: #334155;
}

.pagination .page-link:hover {
    background-color: #dde6f0;
    border-color: #a8b8c8;
    color: #1e293b;
}

[data-bs-theme="light"] .pagination .page-item.disabled .page-link {
    background-color: #e8f0f8;
    color: #64748b;
}

/* Keyboard Navigation Focus */
.row-focus {
    outline: 2px solid #0d6efd;
    outline-offset: -2px;
    background-color: rgba(13, 110, 253, 0.1) !important;
}

[data-bs-theme="dark"] .row-focus {
    outline: 2px solid #0d6efd;
    outline-offset: -2px;
    background-color: rgba(13, 110, 253, 0.2) !important;
}

/* Dark mode form controls */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: #0a0a0a;
    border-color: #1a1a1a;
    color: #e8e8e8;
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    background-color: #111111;
    border-color: #0d6efd;
    color: #fff;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

[data-bs-theme="dark"] .form-control::placeholder {
    color: #555;
}

[data-bs-theme="dark"] .dropdown-menu {
    background-color: #0a0a0a;
    border-color: #1a1a1a;
}

[data-bs-theme="dark"] .dropdown-item {
    color: #e8e8e8;
}

[data-bs-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:focus {
    background-color: #1a1a1a;
    color: #fff;
}

/* Light mode form controls - darker blue tint */
[data-bs-theme="light"] .form-control,
[data-bs-theme="light"] .form-select {
    background-color: #f0f4f8;
    border-color: #a8b8c8;
}

[data-bs-theme="light"] .form-control:focus,
[data-bs-theme="light"] .form-select:focus {
    background-color: #f8fafc;
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

[data-bs-theme="light"] .dropdown-menu {
    background-color: #f0f4f8;
    border-color: #c5d1de;
    box-shadow: 0 4px 12px rgba(100, 116, 139, 0.15);
}

/* ASCII Logo Styling */
.ascii-logo {
    font-size: 12px;
    line-height: 12px;
    transform: scale(0.66);
    transform-origin: top left;
    width: 150%;
    overflow: hidden;
    letter-spacing: 0.5px;
    font-weight: 900 !important;
    padding: 10px 0;
    background-color: transparent;
    /* Faux bold effect */
    text-shadow: 0.5px 0 0 currentColor, -0.5px 0 0 currentColor;
}

/* Prod: White in dark mode, dark gray in light mode for readability if not using a box */
.ascii-logo.text-white {
    color: #212529 !important;
    /* Dark in light mode */
}

[data-bs-theme="dark"] .ascii-logo.text-white {
    color: #ffffff !important;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.2), 0.5px 0 0 #fff;
}

/* Test: Red */
.ascii-logo.text-danger {
    color: #dc3545 !important;
    text-shadow: 0 0 10px rgba(220, 53, 69, 0.2), 0.5px 0 0 currentColor;
}

.nav-pills .nav-link {
    cursor: pointer;
    font-weight: 500;
}

.nav-pills .nav-link:not(.active) {
    background-color: rgba(var(--bs-secondary-rgb), 0.1);
    color: var(--bs-secondary-color);
    border: 1px solid rgba(var(--bs-secondary-rgb), 0.2);
    margin: 0 2px;
}

[data-bs-theme="dark"] .nav-pills .nav-link:not(.active) {
    background-color: #0a0a0a;
    border-color: #1a1a1a;
}

/* ===== Native App-like Controls Bar ===== */
.table-controls-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background: var(--bs-body-bg);
    border-bottom: 1px solid var(--bs-border-color);
    gap: 1rem;
}

.controls-left,
.controls-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.controls-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.control-label {
    font-size: 0.75rem;
    color: var(--bs-secondary-color);
    white-space: nowrap;
}

.control-select {
    padding: 0.35rem 1.75rem 0.35rem 0.5rem;
    font-size: 0.8rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 6px;
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%236c757d' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.4rem center;
    background-size: 12px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.control-select:focus {
    outline: none;
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 2px rgba(var(--bs-primary-rgb), 0.15);
}

.items-count {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--bs-body-color);
}

.items-total {
    color: var(--bs-secondary-color);
    font-weight: 400;
}

.premium-star-sm {
    font-size: 0.65rem;
    margin-left: 0.2rem;
}

/* Dark mode select styling */
[data-bs-theme="dark"] .control-select {
    background-color: #0a0a0a;
    border-color: #2a2a2a;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23888' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}

[data-bs-theme="dark"] .table-controls-bar {
    background: #000;
    border-color: #1a1a1a;
}

/* Tablet - stack controls */
@media (max-width: 768px) {
    .table-controls-bar {
        flex-wrap: wrap;
        padding: 0.5rem 0.75rem;
        gap: 0.5rem;
    }

    .controls-left {
        order: 1;
        flex: 1;
    }

    .controls-center {
        order: 3;
        width: 100%;
        padding-top: 0.25rem;
    }

    .controls-right {
        order: 2;
    }
}

/* Mobile - compact native app style */
@media (max-width: 575.98px) {
    .table-controls-bar {
        padding: 0.4rem 0.5rem;
        gap: 0.25rem;
    }

    .controls-left,
    .controls-right {
        gap: 0.5rem;
    }

    .control-label {
        display: none;
    }

    .control-select {
        padding: 0.3rem 1.5rem 0.3rem 0.4rem;
        font-size: 0.75rem;
        border-radius: 8px;
        min-height: 32px;
    }

    .controls-center {
        order: 2;
        width: auto;
        flex: 1;
        padding-top: 0;
    }

    .controls-right {
        order: 3;
    }

    .items-count {
        font-size: 0.7rem;
    }

    .items-total {
        display: none;
    }

    /* Hide pagination on mobile when infinite scroll enabled */
    body.infinite-scroll-enabled .controls-right {
        display: none;
    }

    body.infinite-scroll-enabled .controls-center {
        flex: 0;
    }

    /* Show infinite scroll loader on mobile */
    body.infinite-scroll-enabled .infinite-scroll-loader {
        display: block;
    }
}

/* Admin Avatar - General's Hat/Helmet Effect */
.admin-circlet {
    position: relative;
    border: 2px solid #4a5568;
    padding: 2px;
    transition: all 0.3s ease;
}

/* General's Hat Brim - positioned above the avatar */
.admin-circlet::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 130%;
    height: 10px;
    background: linear-gradient(180deg, #2d3748 0%, #1a202c 100%);
    border-radius: 50% 50% 0 0;
    border: 2px solid #4a5568;
    border-bottom: none;
    box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

/* Gold Star Badge on the hat */
.admin-circlet::after {
    content: '★';
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: #ffd700;
    text-shadow: 0 0 4px rgba(255, 215, 0, 0.8);
    z-index: 11;
}

.admin-circlet:hover {
    border-color: #ffd700;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    transform: scale(1.1);
}

.admin-circlet:hover::before {
    background: linear-gradient(180deg, #3d4a5c 0%, #2d3748 100%);
    border-color: #ffd700;
}

.admin-circlet:hover::after {
    text-shadow: 0 0 8px rgba(255, 215, 0, 1);
}

/* Scrollbar fallback for Firefox and other non-webkit browsers */
@supports not selector(::-webkit-scrollbar) {
    .table-scroll-container {
        scrollbar-width: thin;
        scrollbar-color: #666 transparent;
    }
}

/* Pull-to-Refresh */
.pull-to-refresh {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    pointer-events: none;
    transform: translateY(-100%);
    transition: transform 0.2s ease-out;
}

.pull-to-refresh.visible {
    transform: translateY(0);
}

.pull-to-refresh-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bs-body-bg);
    border: 2px solid var(--bs-border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--bs-body-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.pull-to-refresh.pulling .pull-to-refresh-icon {
    transform: rotate(180deg);
}

.pull-to-refresh.refreshing .pull-to-refresh-icon {
    animation: ptr-spin 0.8s linear infinite;
    background: var(--bs-primary);
    border-color: var(--bs-primary);
    color: #fff;
}

@keyframes ptr-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

[data-bs-theme="dark"] .pull-to-refresh-icon {
    background: #0a0a0a;
    border-color: #1a1a1a;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

[data-bs-theme="dark"] .pull-to-refresh.refreshing .pull-to-refresh-icon {
    background: #0d6efd;
    border-color: #0d6efd;
}

/* Offline Banner */
.offline-banner {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 8px 16px;
    background: #ffc107;
    color: #000;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 500;
    z-index: 10000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.offline-banner.visible {
    display: flex;
    align-items: center;
    justify-content: center;
}

[data-bs-theme="dark"] .offline-banner {
    background: #856404;
    color: #fff;
}

/* Adjust body padding when offline banner is visible */
body.offline-mode {
    padding-top: 40px !important;
}

@media (max-width: 768px) {
    body.offline-mode {
        padding-top: 36px !important;
    }

    .offline-banner {
        font-size: 0.8rem;
        padding: 6px 12px;
    }
}

/* Mobile header improvements */
@media (max-width: 768px) {
    /* Auth dropdown more touch-friendly */
    .dropdown-toggle {
        padding: 8px !important;
    }

    .dropdown-menu {
        min-width: 180px;
    }

    .dropdown-item {
        padding: 10px 16px;
        font-size: 0.9rem;
    }

    /* Mobile logo area */
    .d-md-none img {
        max-height: 50px;
    }
}

/* Improve row tap feedback on mobile */
@media (hover: none) and (pointer: coarse) {
    .table-hover tbody tr.item-row:active {
        background-color: rgba(var(--bs-primary-rgb), 0.15) !important;
    }

    .action-btn:active {
        transform: scale(0.95);
        opacity: 0.8;
    }
}
.portfolio-slot {
    border: 2px dashed var(--bs-border-color);
    border-radius: 8px;
    padding: 0.5rem;
    min-height: 70px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}
.portfolio-slot.empty:hover {
    border-color: var(--bs-primary);
    background: var(--bs-primary-bg-subtle);
}
.portfolio-slot.filled {
    border-style: solid;
    border-color: var(--bs-border-color);
    background: var(--bs-tertiary-bg);
}
.portfolio-slot .slot-item {
    font-size: 0.75rem;
    font-weight: 600;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    max-width: 100%;
}
.portfolio-slot .slot-qty {
    font-size: 0.65rem;
    color: var(--bs-secondary-color);
}
.portfolio-slot .slot-pl {
    font-size: 0.8rem;
    font-weight: bold;
}
.portfolio-slot .slot-pl.positive { color: var(--bs-success); }
.portfolio-slot .slot-pl.negative { color: var(--bs-danger); }
.portfolio-slot .slot-icon { margin-bottom: 2px; }
.portfolio-slot .slot-actions { position: absolute; top: 4px; right: 4px; display: flex; gap: 2px; opacity: 0; transition: opacity 0.2s ease; z-index: 2; }
.portfolio-slot.filled:hover .slot-actions { opacity: 1; }
.slot-actions .btn { padding: 0.1rem 0.3rem; font-size: 0.65rem; line-height: 1; }
.portfolio-slot .slot-sell-btn { position: absolute; bottom: 4px; right: 4px; font-size: 0.7rem; padding: 0.15rem 0.4rem; opacity: 0; transition: opacity 0.2s ease; }
.portfolio-slot.filled:hover .slot-sell-btn { opacity: 1; }
@media (hover: none) { .portfolio-slot .slot-actions, .portfolio-slot .slot-sell-btn { opacity: 1; } }
#portfolio-collapse-icon {
    transition: transform 0.2s ease;
}
/* Icon starts pointing down (collapsed), rotates up when expanded */
#portfolio-collapse-icon.expanded {
    transform: rotate(180deg);
}
/* Quick Add Autocomplete - CSP compliant (no inline styles) */
.autocomplete-dropdown {
    display: none;
    z-index: 1050;
    max-height: 200px;
    overflow-y: auto;
}
.autocomplete-dropdown.show {
    display: block;
}
.autocomplete-dropdown .autocomplete-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid var(--bs-border-color-translucent);
}
.autocomplete-dropdown .autocomplete-item:last-child {
    border-bottom: none;
}
.autocomplete-dropdown .autocomplete-item:hover,
.autocomplete-dropdown .autocomplete-item.active {
    background: var(--bs-primary-bg-subtle);
}
.autocomplete-dropdown .item-name {
    font-weight: 500;
}
.autocomplete-dropdown .item-price {
    font-size: 0.75rem;
    color: var(--bs-secondary-color);
}
.autocomplete-dropdown .item-id {
    font-size: 0.7rem;
    color: var(--bs-tertiary-color);
}
.quick-add-form {
    border-color: var(--bs-border-color) !important;
}
/* Hidden by default, shown via JS */
.d-none-initial {
    display: none;
}
