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

/* Theme Variables */
:root {
    --bg-primary: #e2e4ea;
    --bg-secondary: white;
    --bg-tertiary: #f8f9fa;
    --bg-hover: #f0f0f0;
    --text-primary: #333;
    --text-secondary: #555;
    --text-muted: #666;
    --text-faint: #999;
    --border-color: #ddd;
    --border-light: #eee;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --shadow-hover: rgba(0, 0, 0, 0.15);
    --accent-color: #3498db;
    --accent-hover: #2980b9;
    --header-title: #2c3e50;
    --card-bg: white;
    --input-bg: white;
    --modal-overlay: rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] {
    --bg-primary: #0d1424;
    --bg-secondary: #1f3260;
    --bg-tertiary: #1f2b47;
    --bg-hover: #253555;
    --text-primary: #e8e8e8;
    --text-secondary: #c0c0c0;
    --text-muted: #a0a0a0;
    --text-faint: #707070;
    --border-color: #3a4a6b;
    --border-light: #2a3a5b;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --shadow-hover: rgba(0, 0, 0, 0.4);
    --accent-color: #5dade2;
    --accent-hover: #3498db;
    --header-title: #e8e8e8;
    --card-bg: #1f3260;
    --input-bg: #1f2b47;
    --modal-overlay: rgba(0, 0, 0, 0.85);
}

body {
    font-family: 'Lexend', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

button,
input,
select,
textarea {
    font-family: inherit;
}

.container {
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px var(--shadow-color);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    cursor: pointer;
}

.header-brand:hover {
    opacity: 0.8;
}

.header-logo {
    height: 40px;
    width: auto;
}

/* The logo PNG is solid red; in dark mode silhouette it to white. */
[data-theme="dark"] .header-logo {
    filter: brightness(0) invert(1);
}

.header h1 {
    font-size: 24px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0;
    color: var(--header-title);
}

.stats {
    color: var(--text-muted);
    font-size: 13px;
}

.stats-updated {
    font-size: 11px;
    color: var(--text-faint);
}

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

#authContainer {
    display: flex;
    align-items: center;
    gap: 8px;
}

#headerNellisActions {
    display: flex;
    align-items: center;
}

.user-email {
    color: var(--text-muted);
    font-size: 11px;
}

.email-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 11px;
    color: var(--text-muted);
}

.email-toggle:hover {
    background: var(--bg-hover);
}

/* Theme Toggle — pill-sized, matches the neighboring pill controls */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-muted);
}

.theme-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.theme-toggle svg {
    width: 12px;
    height: 12px;
}

.email-toggle input[type="checkbox"] {
    cursor: pointer;
    width: 12px;
    height: 12px;
    accent-color: #3498db;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 14px;
    white-space: nowrap;
}

/* Search Section */
.search-section {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px var(--shadow-color);
}

.view-controls {
    display: flex;
    gap: 3px;
}

.view-btn {
    padding: 5px 8px;
    border: 1px solid var(--border-color);
    background: var(--input-bg);
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s;
    color: var(--text-primary);
    line-height: 1;
}

.view-btn:hover {
    background: var(--bg-hover);
}

.view-btn.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* Quick Sort Controls */
.quick-sort-controls {
    display: flex;
    gap: 3px;
}

.quick-sort-btn {
    padding: 5px 10px;
    border: 1px solid var(--border-color);
    background: var(--input-bg);
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s;
    color: var(--text-primary);
    line-height: 1;
    font-weight: 500;
    height: 23px;
    /* Fixed height for consistency */
    box-sizing: border-box;
    /* Ensure padding doesn't add to height */
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Save Search button (matches quick-sort-btn) */
.filter-action-btn {
    padding: 5px 10px;
    border: 1px solid var(--border-color);
    background: #95a5a6;
    /* distinct secondary color */
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s;
    line-height: 1;
    font-weight: 500;
    height: 23px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.filter-action-btn:hover {
    background: #7f8c8d;
}

[data-theme="dark"] .filter-action-btn {
    background: #5a6a7a;
}

[data-theme="dark"] .filter-action-btn:hover {
    background: #6a7a8a;
}

.filter-action-btn.disabled-btn {
    opacity: 0.45;
    pointer-events: none;
}

.disabled-tooltip {
    position: relative;
}

.disabled-tooltip[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 4px;
    padding: 4px 8px;
    background: #333;
    color: #fff;
    font-size: 11px;
    white-space: nowrap;
    border-radius: 4px;
    z-index: 100;
    pointer-events: none;
}

.quick-sort-btn:hover {
    background: var(--bg-hover);
}

.quick-sort-btn.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* Status section dividers */
.status-divider {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    margin: 4px 0;
}

.status-divider::before,
.status-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.status-divider-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 2px 10px;
    border-radius: 10px;
    background: var(--bg-tertiary);
}

.status-divider-outbid .status-divider-label {
    background: rgba(231, 76, 60, 0.15);
    color: rgb(231, 76, 60);
}

.status-divider-winning .status-divider-label {
    background: rgba(39, 174, 96, 0.15);
    color: rgb(39, 174, 96);
}

.status-divider-watching .status-divider-label {
    background: rgba(128, 128, 128, 0.15);
    color: var(--text-muted);
}

/* The closed-section wrapper has no margin/padding — the h2 inside
   each subsection provides the top spacing via collapsed margin. */
.closed-section {
    margin: 0;
    padding: 0;
}

/* Big attractive section titles. Uses margin (not padding) for top
   spacing so it collapses uniformly through any ancestor wrappers
   and lines up with the Active heading regardless of nesting. */
.section-title {
    margin: 16px 0;
    padding: 0;
    font-family: 'Lexend Zetta', 'Lexend', sans-serif;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 2px;
    text-align: center;
    text-transform: uppercase;
    line-height: 1.3;
}

.section-title-active {
    color: var(--text-primary);
}

.section-title-won {
    color: rgb(41, 128, 185);
}

.section-title-purchased {
    color: rgb(39, 174, 96);
}

.section-title-attention {
    color: rgb(199, 120, 0);
}

[data-theme="dark"] .section-title-attention {
    color: rgb(255, 179, 0);
}

.section-title-lost {
    color: rgb(90, 90, 90);
}

[data-theme="dark"] .section-title-lost {
    color: rgb(180, 180, 180);
}

.section-title-returns {
    color: rgb(180, 140, 0);
}

[data-theme="dark"] .section-title-returns {
    color: rgb(230, 190, 50);
}

.section-subtitle-scheduled {
    margin: 20px 0 12px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: rgb(41, 128, 185);
}

.returns-section {
    padding: 0;
    margin: 0;
}

.returns-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.return-list-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

.return-list-row:hover {
    background: var(--bg-tertiary);
}

.return-list-thumb {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.return-list-text {
    flex: 1;
    min-width: 0;
}

.return-list-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.item-inv {
    font-size: 11px;
    color: var(--text-muted);
    margin: 2px 0 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.item-inv-label {
    opacity: 0.8;
    margin-right: 4px;
}

.item-inv-prefix {
    opacity: 0.7;
}

.item-inv-last {
    color: var(--text-primary);
    opacity: 1;
}

.return-list-cancel {
    margin-left: auto;
    flex-shrink: 0;
}

.return-list-meta {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 2px;
}

.return-list-deadline {
    font-size: 12px;
    font-weight: 600;
}

.return-list-deadline.deadline-ok { color: rgb(39, 174, 96); }
.return-list-deadline.deadline-soon { color: rgb(180, 140, 0); }
.return-list-deadline.deadline-urgent { color: rgb(211, 84, 0); }
.return-list-deadline.deadline-expired {
    color: var(--text-muted);
    text-decoration: line-through;
}

.return-list-prices {
    font-size: 12px;
    display: flex;
    gap: 6px;
    color: var(--text-muted);
}

.return-list-price-label {
    font-weight: 500;
    opacity: 0.8;
}

.return-list-price-value {
    font-weight: 700;
    color: var(--text-primary);
}

.return-list-price-value.bid-price {
    color: var(--accent-color);
}

.return-list-price-value + .return-list-price-label {
    margin-left: 6px;
}

.return-list-inv {
    margin-left: 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--text-muted);
}

.return-list-inv-label {
    opacity: 0.8;
    margin-right: 4px;
}

.return-list-inv-prefix {
    opacity: 0.7;
}

.return-list-inv-last {
    color: var(--text-primary);
    opacity: 1;
}

/* Subsections have no tinted backgrounds — the section heading +
   tab color signal the section identity. Top spacing comes from the
   nested h2's collapsed margin, not from padding here. */
.closed-section-won,
.closed-section-scheduled,
.closed-section-attention,
.closed-section-purchased,
.closed-section-lost {
    padding: 0;
    margin: 0;
}

.status-divider-won .status-divider-label {
    background: rgba(41, 128, 185, 0.15);
    color: rgb(41, 128, 185);
}

.status-divider-won::before,
.status-divider-won::after {
    background: rgba(41, 128, 185, 0.4);
}

.status-divider-lost .status-divider-label {
    background: rgba(128, 128, 128, 0.15);
    color: rgb(90, 90, 90);
}

[data-theme="dark"] .status-divider-lost .status-divider-label {
    color: rgb(180, 180, 180);
}

.status-divider-lost::before,
.status-divider-lost::after {
    background: rgba(128, 128, 128, 0.4);
}

.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    align-items: stretch; /* Align items to stretch to the same height */
}

#searchInput {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 16px;
    transition: border-color 0.2s;
    background: var(--input-bg);
    color: var(--text-primary);
    height: 48px; /* Explicit height */
    box-sizing: border-box;
}

#searchTipsBtn {
    flex-shrink: 0; /* Prevent shrinking */
    padding: 5px 10px;
    border: 1px solid var(--border-color);
    background: #95a5a6;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s;
    line-height: 1.2; /* Adjusted for two lines */
    font-weight: 500;
    height: 48px; /* Match search input */
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

#searchTipsBtn:hover {
    background: #7f8c8d;
}

[data-theme="dark"] #searchTipsBtn {
    background: #5a6a7a;
}

[data-theme="dark"] #searchTipsBtn:hover {
    background: #6a7a8a;
}


#searchInput:focus {
    outline: none;
    border-color: var(--accent-color);
}

#searchInput::placeholder {
    color: var(--text-faint);
}

.btn-primary,
.btn-secondary {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    height: 48px; /* Match search input */
    box-sizing: border-box;
}

.btn-primary {
    background: var(--accent-color);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

[data-theme="dark"] .btn-secondary {
    background: #5a6a7a;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

[data-theme="dark"] .btn-secondary:hover {
    background: #6a7a8a;
}

/* Filters */
.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
    align-items: end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.filter-group select,
.filter-group input {
    padding: 8px 10px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
    background: var(--input-bg);
    color: var(--text-primary);
}

.filter-group select:focus,
.filter-group input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.filter-group .checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    padding: 8px 0;
}

.filter-group .checkbox-label input[type="checkbox"] {
    cursor: pointer;
    width: 18px;
    height: 18px;
}

/* All filters in one row */
.filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
}

.filter-group-sm {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.filter-group-sm label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
}

.filter-group-sm select {
    padding: 0 6px;
    /* Reduced vertical padding, rely on height */
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 11px;
    /* Match buttons */
    background: var(--input-bg);
    color: var(--text-primary);
    min-width: 70px;
    height: 23px;
    /* Match buttons */
    line-height: 1;
    box-sizing: border-box;
}

.search-help {
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-faint);
}

/* Hide old filter toggle */
.filter-toggle {
    display: none;
}

/* Legacy filters (hidden) */
.filters-main {
    display: none;
}

.filters {
    display: none;
}

/* Results Grid */
.results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

/* Compact View */
.results-compact {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.results-compact .item-card {
    font-size: 12px;
}

.results-compact .item-image {
    height: 130px;
}

.results-compact .item-content {
    padding: 10px;
}

.results-compact .item-title {
    font-size: 12px;
    -webkit-line-clamp: 2;
    margin-bottom: 8px;
}

.results-compact .item-prices {
    gap: 8px;
    padding-top: 6px;
}

.results-compact .item-badges {
    gap: 4px;
    padding-top: 4px;
}

.results-compact .badge {
    font-size: 9px;
    padding: 2px 5px;
}

.results-compact .price-label {
    font-size: 9px;
}

.results-compact .price-value {
    font-size: 12px;
}


/* Mini View - smaller cards */
.results-mini {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
}

.results-mini .item-card {
    font-size: 11px;
}

.results-mini .item-image {
    height: 100px;
}

.results-mini .item-content {
    padding: 8px;
}

.results-mini .item-title {
    font-size: 11px;
    -webkit-line-clamp: 2;
    margin-bottom: 6px;
}

.results-mini .item-prices {
    gap: 6px;
    margin-bottom: 4px;
}

.results-mini .item-badges {
    gap: 3px;
}

.results-mini .badge {
    font-size: 8px;
    padding: 2px 4px;
}

.results-mini .price-label {
    font-size: 8px;
}

.results-mini .price-value {
    font-size: 11px;
}


.results-mini .corner-icon {
    width: 18px;
    height: 18px;
    font-size: 10px;
}

.loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: var(--text-faint);
    font-size: 18px;
}

.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-faint);
}

.no-results h2 {
    font-size: 24px;
    margin-bottom: 10px;
}

/* Item Card */
.item-card {
    background: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px var(--shadow-color);
    transition: all 0.3s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.item-card:hover {
    outline: 3px solid var(--accent-color);
    outline-offset: 2px;
    filter: brightness(1.04);
}

.item-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: var(--bg-hover);
}

.item-content {
    padding: 15px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.item-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--header-title);
    margin-bottom: 12px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Price row with labels */
.item-prices {
    display: flex;
    flex-wrap: wrap;
    row-gap: 2px;
    /* Smaller vertical gap for wrapped lines */
    column-gap: 8px;
    /* Slightly larger horizontal gap */
    margin-top: auto;
    margin-bottom: 8px;
    /* Add space below the prices */
    padding-top: 8px;
    border-top: 1px solid var(--border-light);
}

.price-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    line-height: 1.1;
}

.price-label {
    font-size: 10px;
    color: var(--text-secondary);
    /* Changed from --text-faint to --text-secondary */
    font-weight: 500;
}

.price-value {
    font-weight: 700;
    color: var(--header-title);
    font-size: 14px;
}

.price-value.bid-price {
    color: var(--accent-color);
}

.price-value.min-bid-price {
    color: #27ae60;
    /* A distinct green color for min bid */
}


/* Badge row */
.item-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    padding-top: 6px;
}

/* Legacy support */
.item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
}

.retail-inline {
    font-weight: 700;
    color: var(--header-title);
    font-size: 16px;
    padding-right: 4px;
}

.badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-condition {
    background: #e8f5e9;
    color: #2e7d32;
}

.badge-condition-new {
    background: #e8f5e9;
    color: #2e7d32;
}

.badge-condition-used {
    background: #fff3e0;
    color: #e65100;
}

.badge-location {
    background: #e3f2fd;
    color: #1565c0;
}

.badge-location-mesa {
    background: #ff9800;
    color: white;
}

.badge-location-phoenix {
    background: #9c27b0;
    color: white;
}

[data-theme="dark"] .badge-location-mesa {
    background: #b36a00;
}

[data-theme="dark"] .badge-location-phoenix {
    background: #6a1b7a;
}

.badge-discount {
    background: #e8f5e9;
    color: #2e7d32;
}

.badge-time {
    background: #fff3e0;
    color: #e65100;
}

.badge-bids {
    background: #f3e5f5;
    color: #6a1b9a;
}

.badge-relisted {
    background: #fff3e0;
    color: #f57c00;
    border: 1px solid #ff9800;
}



/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--shadow-color);
}

.pagination button {
    padding: 8px 16px;
    border: 2px solid var(--border-color);
    background: var(--bg-secondary);
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    color: var(--text-primary);
}

.pagination button:hover:not(:disabled) {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination .page-info {
    padding: 0 15px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Authentication Modal */
/* Search Tips Modal */
.modal,
.modal-overlay {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: var(--modal-overlay);
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex; /* Show the modal */
}

.modal-content {
    background: var(--bg-secondary);
    margin: auto;
    padding: 30px;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    position: relative;
    box-shadow: 0 5px 15px var(--shadow-hover);
}

.modal-content h2 {
    margin-top: 0;
    font-size: 22px;
    color: var(--header-title);
}

.modal-content ul {
    list-style: none;
    padding: 0;
}

.modal-content li {
    margin-bottom: 15px;
    line-height: 1.5;
}

.modal-content strong {
    font-weight: 700;
    color: var(--accent-color);
}

.modal-content em {
    font-style: normal;
    background-color: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    color: var(--text-secondary);
}

.close-button {
    color: var(--text-faint);
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-button:hover,
.close-button:focus {
    color: var(--text-primary);
}


.modal-content {
    background: var(--bg-secondary);
    border-radius: 12px;
    max-width: 450px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 40px;
    position: relative;
    box-shadow: 0 8px 32px var(--shadow-hover);
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-faint);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.auth-view h2 {
    margin-bottom: 25px;
    color: var(--header-title);
    font-size: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 16px;
    transition: border-color 0.2s;
    background: var(--input-bg);
    color: var(--text-primary);
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: var(--text-muted);
    font-size: 13px;
}

.error-message {
    color: #e74c3c;
    font-size: 14px;
    margin: 10px 0;
    min-height: 20px;
}

.btn-block {
    width: 100%;
}

.modal-footer {
    text-align: center;
    margin-top: 20px;
    color: var(--text-muted);
    font-size: 14px;
}

.modal-footer a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 600;
}

.modal-footer a:hover {
    text-decoration: underline;
}

.verify-instructions {
    background: var(--bg-tertiary);
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.verify-instructions strong {
    color: var(--header-title);
}

/* Saved Searches Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    background: var(--bg-secondary);
    box-shadow: 2px 0 8px var(--shadow-color);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar.collapsed {
    transform: translateX(-230px);
}

.sidebar-toggle {
    position: absolute;
    right: -40px;
    top: 130px;
    width: 40px;
    height: 40px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 2px 2px 8px var(--shadow-color);
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: var(--text-primary);
}

.sidebar-toggle:hover {
    background: var(--bg-hover);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 2px solid var(--border-light);
}

.sidebar-header h3 {
    font-size: 16px;
    color: var(--header-title);
    margin-bottom: 15px;
}

.sidebar-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.search-item {
    /* Inverted from the main section: the sidebar's surface is the
       "card" tone (var(--card-bg)) so each saved search recesses into
       it using the page-background tone for contrast. */
    background: var(--bg-primary);
    border-radius: 6px;
    padding: 4px 6px;
    margin-bottom: 4px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.search-item:hover {
    background: var(--bg-hover);
}

.search-item.active {
    background: var(--accent-color);
    border-left: 3px solid var(--accent-hover);
}

[data-theme="dark"] .search-item.active {
    background: #2a4a6b;
    border-left-color: var(--accent-color);
}

.search-item.zero-results .search-item-name {
    color: var(--text-faint);
}

.search-item-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 2px;
    gap: 6px;
}

.drag-handle {
    cursor: grab;
    color: var(--text-faint);
    font-size: 12px;
    padding: 0 2px;
    user-select: none;
    line-height: 1;
}

.drag-handle:hover {
    color: var(--text-muted);
}

.sortable-ghost {
    opacity: 0.4;
    background: var(--bg-hover);
}

.search-item-name {
    font-weight: 600;
    color: var(--header-title);
    font-size: 12px;
    flex: 1;
    min-width: 0;
    line-height: 1.3;
    display: flex;
    align-items: center;
    gap: 6px;
}

.search-item-query-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-item-delete {
    background: none;
    border: none;
    color: var(--text-faint);
    cursor: pointer;
    font-size: 14px;
    padding: 0;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: all 0.2s;
}

.search-item-delete:hover {
    background: #e74c3c;
    color: white;
}

.search-item-query {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
}

.search-count {
    display: inline-block;
    padding: 2px 5px;
    background: var(--accent-color);
    color: white;
    border-radius: 9px;
    font-size: 10px;
    font-weight: 600;
    margin-left: 5px;
    vertical-align: middle;
}

.search-count.zero {
    background: var(--border-color);
    color: var(--text-muted);
}

.sidebar-collapsed-margin {
    margin-left: 50px;
}

.sidebar-visible {
    margin-left: 280px;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 10px;
        margin-left: 0 !important;
        /* No sidebar margin on mobile */
    }

    .header {
        position: relative;
        padding: 10px;
        gap: 8px;
    }

    .header-top {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .header h1 {
        font-size: 14px;
        margin: 0;
    }

    .header-logo {
        height: 28px;
    }

    /* Sidebar tab sits at a smaller offset on mobile since the
       header is shorter. */
    .sidebar-toggle {
        top: 100px;
    }

    .header-brand {
        gap: 8px;
    }

    #authContainer {
        gap: 6px;
    }

    /* Swap the long label for the short "Active" on mobile and drop
       the bullseye icon. Selectors prefixed with #headerNellisActions
       to outrank the default .nellis-active-label-short { display:
       none } rule that's defined later in the stylesheet. */
    #headerNellisActions .nellis-active-label-long {
        display: none;
    }
    #headerNellisActions .nellis-active-label-short {
        display: inline;
    }
    #headerNellisActions .nellis-icon {
        display: none;
    }
    #headerNellisActions .nellis-count {
        display: none;
    }

    /* Mobile: hide the empty (hover-reveal) heart entirely so it
       doesn't create an invisible 22×22 touch target in the corner
       that intercepts the first tap. The filled heart on watched
       items stays visible. Long-press-to-watch handles adding. */
    .corner-heart[data-watching="0"] {
        display: none;
    }

    /* Mobile tabs: stack label over count and tighten padding so all
       five tabs fit on a single row without scrolling. */
    .active-items-tabs {
        gap: 0;
    }
    .ai-tab {
        flex-direction: column;
        align-items: center;
        gap: 2px;
        padding: 6px 8px;
        font-size: 12px;
        line-height: 1.1;
    }
    .ai-tab-count {
        font-size: 10px;
        padding: 0 5px;
    }

    /* Disable the iOS long-press callout (image preview, text select)
       on cards so our long-press-to-watch gesture has a clean surface. */
    .item-card {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }

    /* Shrink the Active button on mobile so it fits on the top row
       next to the title. */
    #headerNellisActions .nellis-active-btn {
        height: 30px;
        padding: 0 10px;
        font-size: 13px;
    }
    #headerNellisActions .nellis-refresh-btn {
        height: 30px;
        width: 30px;
        font-size: 14px;
    }

    .stats {
        font-size: 11px;
    }

    /* Simplified mobile search bar */
    .search-bar {
        flex-direction: row;
        gap: 8px;
    }

    .search-bar input {
        flex: 1;
        min-width: 0;
    }

    .fuzzy-toggle {
        display: none;
        /* Hide fuzzy toggle on mobile */
    }

    /* Mobile filters layout */
    .filters-row {
        flex-wrap: wrap;
        gap: 6px;
    }

    .filter-group-sm select {
        min-width: 60px;
        font-size: 11px;
        padding: 4px 5px;
    }

    .filter-group-sm label {
        font-size: 9px;
    }

    .search-help {
        display: none;
    }

    /* Two-column grid for results (default/large view becomes 1 column) */
    .results {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    /* Compact cards for mobile */
    .item-title {
        font-size: 11px;
        line-height: 1.3;
        max-height: 2.6em;
    }

    .item-prices {
        gap: 6px;
        padding-top: 6px;
    }

    .item-badges {
        gap: 3px;
    }

    .price-label {
        font-size: 8px;
    }

    .price-value {
        font-size: 11px;
    }

    .badge {
        font-size: 8px;
        padding: 2px 4px;
    }

    .pagination {
        flex-wrap: wrap;
        gap: 8px;
    }

    .pagination button {
        padding: 8px 12px;
        font-size: 13px;
    }

    .page-info {
        font-size: 13px;
    }

    /* Sidebar fixes for mobile */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 80%;
        max-width: 280px;
        height: 100vh;
        transform: translateX(-100%);
        z-index: 1000;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.2);
    }

    .sidebar.collapsed {
        transform: translateX(-100%);
    }

    .sidebar:not(.collapsed) {
        transform: translateX(0);
    }

    /* Hide the toggle tab when the sidebar is open on mobile —
       tapping the overlay or swiping closes it. */
    .sidebar:not(.collapsed) .sidebar-toggle {
        display: none;
    }

    /* Overlay when sidebar is open */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .sidebar-visible {
        margin-left: 0;
    }

    .modal-content {
        padding: 30px 20px;
        max-width: 90%;
    }

    /* Compact view on mobile (two columns) */
    .results-compact {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    /* Mini view on mobile (three columns) */
    .results-mini {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .results-mini .item-image {
        height: 70px;
    }

    .results-mini .item-title {
        font-size: 9px;
    }

    .results-mini .badge {
        font-size: 7px;
        padding: 1px 3px;
    }
}

/* ========== Active Items: tab navigation ========== */

.active-items-tabs {
    display: flex;
    gap: 4px;
    margin: 16px 0 8px;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    /* Hide native scrollbar so the tab strip stays clean on overflow */
    scrollbar-width: none;
    /* Stick to the viewport top while the page scrolls under it. */
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-primary);
}
.active-items-tabs::-webkit-scrollbar { display: none; }

.ai-tab {
    background: none;
    border: none;
    padding: 8px 14px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
}

/* Small refresh button at the left of the tab strip — visually
   distinct from a tab (no underline state) but matches the strip's
   muted color. */
.ai-refresh-btn {
    background: none;
    border: none;
    padding: 0 10px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 4px;
    margin-bottom: -1px;
    transition: color 0.15s;
}

.ai-refresh-btn:hover {
    color: var(--accent-color);
}

.ai-refresh-btn.spinning {
    animation: spin 1s linear infinite;
}

.ai-tab:hover {
    color: var(--text-primary);
}

.ai-tab[data-active="1"] {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
}

.ai-tab-count {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
}

.ai-tab[data-active="1"] .ai-tab-count {
    background: var(--accent-color);
    color: white;
}

/* Section visibility per selected tab.
   When body[data-active-items-tab] is set, hide everything that
   doesn't belong to the current tab. */

/* "active" tab: hide closed sections and returns list */
body[data-active-items-tab="active"] .closed-section,
body[data-active-items-tab="active"] .returns-section {
    display: none;
}

/* "pickups" tab: show only the Pick Ups sub-section */
body[data-active-items-tab="pickups"] .active-section-title,
body[data-active-items-tab="pickups"] #results,
body[data-active-items-tab="pickups"] .closed-section-lost,
body[data-active-items-tab="pickups"] .closed-section-attention,
body[data-active-items-tab="pickups"] .closed-section-purchased,
body[data-active-items-tab="pickups"] .returns-section {
    display: none;
}

/* "purchased" tab: show only the Purchased sub-section */
body[data-active-items-tab="purchased"] .active-section-title,
body[data-active-items-tab="purchased"] #results,
body[data-active-items-tab="purchased"] .closed-section-lost,
body[data-active-items-tab="purchased"] .closed-section-won,
body[data-active-items-tab="purchased"] .returns-section {
    display: none;
}

/* "returns" tab: show only the Returns list */
body[data-active-items-tab="returns"] .active-section-title,
body[data-active-items-tab="returns"] #results,
body[data-active-items-tab="returns"] .closed-section {
    display: none;
}

/* "lost" tab: show only the Lost sub-section */
body[data-active-items-tab="lost"] .active-section-title,
body[data-active-items-tab="lost"] #results,
body[data-active-items-tab="lost"] .closed-section-won,
body[data-active-items-tab="lost"] .closed-section-attention,
body[data-active-items-tab="lost"] .closed-section-purchased,
body[data-active-items-tab="lost"] .returns-section {
    display: none;
}

/* ========== Nellis Account Integration ========== */

#headerNellisActions #nellisActions {
    display: flex;
    align-items: center;
    gap: 8px;
}

#headerNellisActions #nellisActions.hidden {
    display: none;
}

#headerNellisActions .nellis-active-btn {
    flex: 0 0 auto;
    height: 36px;
    padding: 0 14px;
    font-size: 14px;
}

/* Match the Active Items button's gray-filled look so the pair
   reads as one control group rather than two different styles. */
#headerNellisActions .nellis-refresh-btn {
    height: 36px;
    width: 36px;
    font-size: 16px;
    background: #95a5a6;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    transition: all 0.2s;
}

#headerNellisActions .nellis-refresh-btn:hover {
    background: var(--accent-color);
    color: white;
}

[data-theme="dark"] #headerNellisActions .nellis-refresh-btn {
    background: #5a6a7a;
}

/* Active Items label: long on desktop, short ("Active") on mobile */
.nellis-active-label-short {
    display: none;
}

/* Profile modal body */
.profile-modal-content {
    max-width: 360px;
}

.profile-email {
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
    padding: 8px 0 16px;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 16px;
    word-break: break-all;
}

.profile-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.profile-row {
    width: 100%;
    justify-content: center;
    padding: 10px 14px;
    font-size: 14px;
}

.profile-row.email-toggle {
    /* Override pill sizing for the modal context */
    font-size: 14px;
    padding: 10px 14px;
    gap: 10px;
}

.profile-row.email-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

.nellis-link-btn {
    font-size: 11px;
    padding: 2px 8px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    border-radius: 4px;
    cursor: pointer;
}

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

#nellisActions {
    display: flex;
    gap: 8px;
    align-items: center;
}

#nellisActions.hidden {
    display: none;
}

.nellis-active-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 6px;
    transition: all 0.2s;
}

.nellis-active-btn:hover {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.nellis-active-btn.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.nellis-icon {
    font-size: 14px;
}

.nellis-count {
    background: rgba(255, 255, 255, 0.2);
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.nellis-refresh-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    border-radius: 6px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.nellis-refresh-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nellis-refresh-btn.spinning {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Item card Nellis status indicators - background colors on content area */
/* Order matters: winning/outbid override watching */
.item-card.nellis-watching .item-content {
    background: rgba(128, 128, 128, 0.5);
}

.item-card.nellis-outbid .item-content {
    background: rgba(231, 76, 60, 0.5);
}

.item-card.nellis-winning .item-content {
    background: rgba(39, 174, 96, 0.5);
}

[data-theme="dark"] .item-card.nellis-watching .item-content {
    background: rgba(128, 128, 128, 0.5);
}

[data-theme="dark"] .item-card.nellis-outbid .item-content {
    background: rgba(231, 76, 60, 0.5);
}

[data-theme="dark"] .item-card.nellis-winning .item-content {
    background: rgba(39, 174, 96, 0.5);
}

/* Active-item state is signaled via the .item-content tint and the
   corner W/O badges; no card border or glow. */

.item-card.nellis-won {
    border: none;
    box-shadow: none;
}

.item-card.nellis-cancelled {
    border-color: rgba(128, 128, 128, 0.7);
    box-shadow: none;
    background-image: repeating-linear-gradient(
        135deg,
        rgba(128, 128, 128, 0.18) 0,
        rgba(128, 128, 128, 0.18) 10px,
        rgba(128, 128, 128, 0.32) 10px,
        rgba(128, 128, 128, 0.32) 20px
    );
}

.item-card.nellis-cancelled .item-content {
    background: rgba(255, 255, 255, 0.55);
}

[data-theme="dark"] .item-card.nellis-cancelled .item-content {
    background: rgba(0, 0, 0, 0.55);
}

.item-card.nellis-scheduled {
    border: none;
    box-shadow: none;
}

.item-card.nellis-scheduled .item-content {
    background: rgba(52, 152, 219, 0.5);
}

[data-theme="dark"] .item-card.nellis-scheduled .item-content {
    background: rgba(52, 152, 219, 0.5);
}

/* Return statuses on purchased cards */
.item-card.nellis-return-init {
    position: relative;
    border: 3px solid rgb(231, 76, 60);
    box-shadow: 0 0 12px rgba(231, 76, 60, 0.6);
}

.item-card.nellis-return-init::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    background-image: repeating-linear-gradient(
        135deg,
        rgba(231, 76, 60, 0.3) 0,
        rgba(231, 76, 60, 0.3) 10px,
        rgba(231, 76, 60, 0.5) 10px,
        rgba(231, 76, 60, 0.5) 20px
    );
}

.item-card.nellis-return-received {
    position: relative;
    border: 3px solid rgb(243, 156, 18);
    box-shadow: 0 0 12px rgba(243, 156, 18, 0.6);
}

.item-card.nellis-return-received::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    background-image: repeating-linear-gradient(
        135deg,
        rgba(243, 156, 18, 0.3) 0,
        rgba(243, 156, 18, 0.3) 10px,
        rgba(243, 156, 18, 0.5) 10px,
        rgba(243, 156, 18, 0.5) 20px
    );
}

.item-card.nellis-return-processed {
    position: relative;
    border: 3px solid rgb(241, 196, 15);
    box-shadow: 0 0 12px rgba(241, 196, 15, 0.6);
}

.item-card.nellis-return-processed::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    background-image: repeating-linear-gradient(
        135deg,
        rgba(241, 196, 15, 0.3) 0,
        rgba(241, 196, 15, 0.3) 10px,
        rgba(241, 196, 15, 0.5) 10px,
        rgba(241, 196, 15, 0.5) 20px
    );
}

.item-card.nellis-return-refunded {
    position: relative;
    border: 3px solid rgb(46, 204, 113);
    box-shadow: 0 0 12px rgba(46, 204, 113, 0.6);
}

.item-card.nellis-return-refunded::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    background-image: repeating-linear-gradient(
        135deg,
        rgba(46, 204, 113, 0.3) 0,
        rgba(46, 204, 113, 0.3) 10px,
        rgba(46, 204, 113, 0.5) 10px,
        rgba(46, 204, 113, 0.5) 20px
    );
}

/* Stuck returns: in progress but lingering past the return window. A pulsing
   amber ring draws the eye in the "Needs Attention" section. The ring rides on
   top of whatever status border/stripe the card already has. */
@keyframes returnStuckPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 171, 0, 0); }
    50%      { box-shadow: 0 0 14px 3px rgba(255, 171, 0, 0.85); }
}

.item-card.nellis-return-stuck {
    animation: returnStuckPulse 1.6s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
    .item-card.nellis-return-stuck {
        animation: none;
        box-shadow: 0 0 12px 2px rgba(255, 171, 0, 0.8);
    }
}

/* Return-progress stepper overlaid on the bottom edge of the card image.
   Four segments light up cumulatively in per-stage colors. */
.item-image-wrap {
    position: relative;
}

/* Return-progress stepper: circular nodes on a connecting track with tiny
   all-caps labels. Lives in an opaque bar over the bottom of the card image.
   The connector leading into a reached stage is solid blue; the connector into
   the stage currently being worked toward is half-filled. */
.return-stepper {
    position: absolute;
    left: 6px;
    right: 6px;
    bottom: 6px;
    display: flex;
    padding: 6px 8px 5px;
    background: rgba(18, 18, 18, 0.80);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    z-index: 3;  /* above the diagonal status stripe (card ::after, z-index 2) */
}

/* Large (grid) cards sit the bar a touch higher off the bottom edge. */
.results-grid .return-stepper {
    bottom: 11px;
}

.return-step {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.return-step-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    /* Transparent so the dot interior matches the bar around it; the connector
       lines are inset to stop at the dot edges, so nothing shows through. */
    background: transparent;
    box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.45);
    z-index: 1;
}

/* Per-stage colors, advancing red → orange → yellow → green as the return
   moves down the pipeline. Stages always render in fixed order, so position
   maps cleanly: 1 INIT, 2 RCVD, 3 PROC, 4 RFND. */
.return-step:nth-child(1) { --step-color: rgb(231, 76, 60); }   /* red    */
.return-step:nth-child(2) { --step-color: rgb(230, 126, 34); }  /* orange */
.return-step:nth-child(3) { --step-color: rgb(241, 196, 15); }  /* yellow */
.return-step:nth-child(4) { --step-color: rgb(46, 204, 113); }  /* green  */

.return-step.done .return-step-dot {
    background: var(--step-color);
    box-shadow: inset 0 0 0 1.5px var(--step-color);
    position: relative;
}

/* Green check overlaid on the final dot once the refund lands. */
.return-step-check {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    font-weight: 900;
    line-height: 1;
    color: #fff;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.9);
    z-index: 2;
}

.return-step.current .return-step-dot {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--step-color) 40%, transparent),
                inset 0 0 0 1.5px var(--step-color);
}

.return-step-label {
    margin-top: 4px;
    font-size: 7px;
    line-height: 1;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    white-space: nowrap;
    color: rgba(255, 255, 255, 0.50);
}

.return-step.done .return-step-label {
    color: #fff;
}

/* Connector track segment leading into each node (drawn behind the dots). */
.return-step:not(:first-child)::before {
    content: "";
    position: absolute;
    top: 5px;
    /* Span only the gap between dots: inset by the dot radius (5.5px) on each
       side so the line touches the dot edges but never crosses inside them. */
    left: calc(-50% + 5.5px);
    width: calc(100% - 11px);
    height: 2px;
    background: rgba(255, 255, 255, 0.20);
    z-index: 0;
}

.return-step.conn-full::before {
    background: var(--step-color);
}

.return-step.conn-half::before {
    background: linear-gradient(to right, var(--step-color) 50%, rgba(255, 255, 255, 0.20) 50%);
}

.results-mini .return-step-dot {
    width: 9px;
    height: 9px;
}

.results-mini .return-step:not(:first-child)::before {
    top: 4px;
    left: calc(-50% + 4.5px);
    width: calc(100% - 9px);
}

.results-mini .return-step-label {
    font-size: 6px;
    letter-spacing: 0.3px;
}

.status-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px dashed rgba(128, 128, 128, 0.3);
    font-size: 12px;
    font-weight: 600;
}

.status-line + .status-line {
    margin-top: 2px;
    padding-top: 0;
    border-top: none;
}

.status-line-won-row {
    gap: 6px;
}

.won-row-right {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
}

.return-btn {
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: transparent;
    color: inherit;
    border: 1px solid currentColor;
    border-radius: 3px;
    cursor: pointer;
    transition: opacity 0.15s;
}

.return-btn:hover:not(:disabled) {
    opacity: 0.7;
}

.return-btn:disabled {
    opacity: 0.5;
    cursor: wait;
}

.status-line-label {
    opacity: 0.7;
    font-weight: 500;
}

.status-line-value {
    font-weight: 700;
}

.status-line-days {
    opacity: 0.85;
}

.status-line.deadline-ok {
    color: rgb(39, 174, 96);
}

.status-line.deadline-soon {
    color: rgb(180, 140, 0);
}

.status-line.deadline-urgent {
    color: rgb(211, 84, 0);
}

.status-line.deadline-expired {
    color: var(--text-muted);
    text-decoration: line-through;
}

.status-line.status-line-muted {
    color: var(--text-muted);
}

.status-chip {
    display: inline-block;
    margin-left: 4px;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-chip-init {
    background: rgba(231, 76, 60, 0.2);
    color: rgb(192, 57, 43);
}

.status-chip-received {
    background: rgba(243, 156, 18, 0.2);
    color: rgb(180, 95, 6);
}

.status-chip-processed {
    background: rgba(39, 174, 96, 0.2);
    color: rgb(30, 132, 73);
}

.status-chip-stuck {
    background: rgba(255, 171, 0, 0.22);
    color: rgb(176, 118, 0);
}

[data-theme="dark"] .status-chip-stuck {
    color: rgb(255, 196, 64);
}

/* Refunded chip: dark-on-light contrast so it stays legible under the
   card's grayscale + reduced-opacity treatment */
.status-chip-refunded {
    background: rgba(80, 80, 80, 0.9);
    color: #fff;
}

.status-chip-cancel {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    margin-left: 4px;
    padding: 0;
    font-family: Arial, sans-serif;
    font-size: 14px;
    line-height: 1;
    font-weight: 400;
    background: transparent;
    color: inherit;
    border: 1px solid currentColor;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.15s;
    vertical-align: middle;
}

.status-chip-cancel:hover:not(:disabled) {
    opacity: 1;
}

.status-chip-cancel:disabled {
    opacity: 0.4;
    cursor: wait;
}

/* Toast notifications */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10001;
    pointer-events: none;
}

.toast {
    background: #2c3e50;
    color: #fff;
    padding: 10px 18px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.2s, transform 0.2s;
}

.toast.toast-show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success { background: rgb(39, 174, 96); }
.toast-error { background: rgb(231, 76, 60); }

/* Floating tooltip rendered at document level to escape card overflow */
.floating-tooltip {
    position: fixed;
    padding: 4px 8px;
    background: #333;
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    border-radius: 4px;
    z-index: 10000;
    pointer-events: none;
}

.floating-tooltip.wrap {
    white-space: normal;
    max-width: 280px;
    word-break: break-word;
}

.status-chip-scheduled {
    background: rgba(52, 152, 219, 0.2);
    color: rgb(41, 128, 185);
}

.status-chip-cancelled {
    background: rgba(128, 128, 128, 0.25);
    color: var(--text-muted);
}

.pickup-location-header {
    margin: 12px 0 4px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.closed-section-scheduled {
    margin-bottom: 16px;
}

.status-divider-purchased .status-divider-label {
    background: rgba(39, 174, 96, 0.15);
    color: rgb(39, 174, 96);
}

.status-divider-purchased::before,
.status-divider-purchased::after {
    background: rgba(39, 174, 96, 0.4);
}

.status-divider-notice {
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin: -2px 0 6px;
}

.status-divider-notice.deadline-ok { color: rgb(39, 174, 96); }
.status-divider-notice.deadline-soon { color: rgb(180, 140, 0); }
.status-divider-notice.deadline-urgent { color: rgb(211, 84, 0); }
.status-divider-notice.deadline-expired {
    color: var(--text-muted);
    text-decoration: line-through;
}

.item-card.nellis-lost {
    border: none;
    box-shadow: none;
    opacity: 0.7;
}

.item-card.nellis-lost .item-content {
    background: rgba(128, 128, 128, 0.3);
}

/* Corner icons container (top right) */
.corner-icons {
    position: absolute;
    top: 6px;
    right: 6px;
    display: flex;
    gap: 4px;
    z-index: 2;
    pointer-events: none;
}


.corner-icon {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.corner-heart {
    background: rgba(108, 117, 125, 0.95);
    color: white;
    font-size: 13px;
    cursor: pointer;
    /* Heart is interactive even though its parent .corner-icons has
       pointer-events: none (so the rest of the card stays clickable). */
    pointer-events: auto;
    transition: opacity 0.15s, transform 0.1s;
}

.corner-heart::before {
    content: '♡';
}

.corner-heart[data-watching="1"]::before {
    content: '❤';
}

/* Empty heart is invisible by default, fades in on card hover and is
   always visible while busy (during an in-flight toggle). */
.corner-heart[data-watching="0"] {
    opacity: 0;
}

.item-card:hover .corner-heart[data-watching="0"],
.corner-heart[data-busy="1"] {
    opacity: 1;
}

.corner-heart:hover {
    transform: scale(1.1);
}

.corner-heart[data-busy="1"] {
    cursor: progress;
}

/* Brief scale animation triggered when a long-press toggles watch
   on touch devices — gives visual confirmation the gesture fired. */
@keyframes heart-pop {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.6); }
    100% { transform: scale(1); }
}
.corner-heart.long-press-pop {
    animation: heart-pop 0.35s ease-out;
}

.corner-winning {
    background: rgba(39, 174, 96, 0.95);
    color: white;
}

.corner-outbid {
    background: rgba(231, 76, 60, 0.95);
    color: white;
}

.corner-won {
    background: rgba(39, 174, 96, 0.95);
    color: white;
}

.corner-lost {
    background: transparent;
    box-shadow: none;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    font-size: 16px;
}

/* Watching badge */
.badge-watching {
    background: #6c757d;
    color: white;
}

/* Make item-card position relative for corner icon positioning */
.item-card {
    position: relative;
}

/* Winning/Outbid badges */
.badge-winning {
    background: #27ae60;
    color: white;
}

.badge-outbid {
    background: #e74c3c;
    color: white;
}

/* Current bid display in active items */
.current-bid {
    font-weight: 700;
    color: var(--accent-color);
    font-size: 14px;
}

[data-theme="dark"] .watch-heart {
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* Corner time display (top left) */
.corner-time-display {
    position: absolute;
    top: 6px;
    left: 6px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    z-index: 2;
    pointer-events: none;
}