*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Consolas', 'SF Mono', 'Menlo', monospace; background: #0d0d0d; color: #d4d4d4; min-height: 100vh; font-size: 15px; transition: background .3s ease, color .3s ease; }
a { color: #14b8a6; text-decoration: none; }
a:hover { text-decoration: underline; color: #5eead4; }
::selection { background: #14b8a6; color: #0d0d0d; }

/* Hide number input spinners */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

/* Scrollbars */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: #1a1a1a; }
::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #666; }

/* Tooltip */
.tooltip-wrap { position: relative; display: inline-block; cursor: help; }
.tooltip-wrap .tooltip-icon { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; background: #333; font-size: 0.7rem; font-weight: 700; color: #999; }
.tooltip-wrap .tooltip-text { visibility: hidden; opacity: 0; position: absolute; top: 130%; left: 50%; transform: translateX(-50%); background: #14b8a6; color: #0d0d0d; padding: 6px 10px; border-radius: 4px; font-size: 0.72rem; white-space: nowrap; z-index: 2000; transition: opacity .15s; pointer-events: none; font-weight: 600; }
.tooltip-wrap .tooltip-text::after { content: ''; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); border: 5px solid transparent; border-bottom-color: #14b8a6; }
.tooltip-wrap:hover .tooltip-text { visibility: visible; opacity: 1; }

/* Buttons */
.btn { padding: 6px 14px; border: none; border-radius: 3px; font-size: 0.82rem; font-weight: 600; cursor: pointer; transition: background .12s, opacity .12s; font-family: inherit; }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-primary { background: #14b8a6; color: #0d0d0d; }
.btn-primary:hover:not(:disabled) { background: #5eead4; }
.btn-green { background: #2ea043; color: #fff; }
.btn-green:hover:not(:disabled) { background: #3fb950; }
.btn-outline { background: transparent; border: 1px solid #444; color: #aaa; }
.btn-outline:hover:not(:disabled) { background: #1a1a1a; color: #14b8a6; border-color: #14b8a6; }
.btn-sm { padding: 4px 10px; font-size: 0.78rem; }

input[type="file"] { display: none; }

/* Results Panel */
.results-panel { padding: 4px 8px 4px; }

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 4px; }
.toolbar .spacer { flex: 1; }
.search-box { padding: 4px 10px; border: 1px solid #444; border-radius: 3px; font-size: 0.82rem; width: 200px; outline: none; background: #1a1a1a; color: #d4d4d4; font-family: inherit; }
.search-box:focus { border-color: #14b8a6; }

select, select.mp-select, select.page-size-select { padding: 4px 8px; border: 1px solid #444; border-radius: 3px; font-size: 0.8rem; background: #1a1a1a; color: #d4d4d4; font-family: inherit; }
select:focus { border-color: #14b8a6; outline: none; }

/* Conversion rate fields */
.rate-group { display: flex; gap: 4px; align-items: center; }
.rate-label { font-size: 0.7rem; color: #666; font-weight: 600; letter-spacing: 0.3px; }
.rate-input { width: 58px; padding: 3px 5px; border: 1px solid #333; border-radius: 3px; background: #1a1a1a; color: #14b8a6; font-family: inherit; font-size: 0.78rem; text-align: right; font-weight: 600; outline: none; }
.rate-input:focus { border-color: #14b8a6; }
body.light .rate-label { color: #888; }
body.light .rate-input { background: #fff; border-color: #ccc; color: #0d9488; }
body.light .rate-input:focus { border-color: #0d9488; }

/* Columns dropdown */
.cols-dropdown { position: relative; display: inline-block; }
.cols-dropdown-body { display: none; position: fixed; background: #1a1a1a; border: 1px solid #444; border-radius: 4px; box-shadow: 0 4px 16px rgba(0,0,0,0.5); z-index: 1000; padding: 8px; min-width: 200px; max-height: 360px; overflow-y: auto; }
.cols-dropdown-body.open { display: block; }
.cols-dropdown-body label { display: block; padding: 2px 4px; font-size: 0.8rem; cursor: pointer; white-space: nowrap; color: #aaa; }
.cols-dropdown-body label:hover { background: #252525; color: #14b8a6; }

/* Table wrapper */
.table-wrap { overflow: auto; background: #111; border: 1px solid #2a2a2a; max-height: calc(100vh - 130px); margin-bottom: 90px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
td.col-name, th.col-name { max-width: 250px; overflow: hidden; text-overflow: ellipsis; }

/* Header */
thead tr:first-child th { position: sticky; top: 0; background: #1a1a1a; color: #14b8a6; padding: 6px 6px; font-size: 0.78rem; font-weight: 700; text-align: left; cursor: pointer; user-select: none; white-space: nowrap; border-right: 1px solid #2a2a2a; border-bottom: 2px solid #14b8a6; z-index: 11; text-transform: uppercase; letter-spacing: 0.3px; }
thead th:last-child { border-right: none; }
thead th .sort-arrow { margin-left: 2px; font-size: 0.65rem; opacity: 0.4; }
thead th .sort-arrow.active { opacity: 1; color: #14b8a6; }
thead th .resize-handle { position: absolute; right: 0; top: 0; bottom: 0; width: 5px; cursor: col-resize; }
thead th .resize-handle:hover { background: rgba(20,184,166,0.3); }

/* Filter row */
thead tr.filter-row th { background: #151515; padding: 3px 3px; position: sticky; top: var(--header-h, 32px); z-index: 9; border-bottom: 1px solid #2a2a2a; border-right: 1px solid #2a2a2a; }
thead tr.filter-row th input { width: 100%; padding: 2px 4px; border: 1px solid #333; border-radius: 2px; font-size: 0.75rem; background: #0d0d0d; color: #d4d4d4; outline: none; font-family: inherit; }
thead tr.filter-row th input:focus { border-color: #14b8a6; }
thead tr.filter-row th input::placeholder { color: #555; }

.filter-btn { background: none; border: 1px solid #333; border-radius: 2px; color: #888; font-size: 0.7rem; padding: 1px 5px; cursor: pointer; width: 100%; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: inherit; }
.filter-btn:hover { background: #1a1a1a; color: #14b8a6; border-color: #14b8a6; }
.filter-btn.active { border-color: #14b8a6; color: #14b8a6; }

/* Set filter popup */
.set-filter-popup { position: fixed; background: #1a1a1a; border: 1px solid #444; border-radius: 4px; box-shadow: 0 4px 20px rgba(0,0,0,0.6); z-index: 1000; padding: 10px; min-width: 180px; max-width: 280px; color: #d4d4d4; }
.set-filter-popup .sf-search { width: 100%; padding: 4px 8px; border: 1px solid #444; border-radius: 3px; font-size: 0.8rem; margin-bottom: 6px; outline: none; background: #0d0d0d; color: #d4d4d4; font-family: inherit; }
.set-filter-popup .sf-search:focus { border-color: #14b8a6; }
.set-filter-popup .sf-actions { display: flex; gap: 8px; margin-bottom: 6px; font-size: 0.76rem; }
.set-filter-popup .sf-actions a { color: #14b8a6; cursor: pointer; text-decoration: none; }
.set-filter-popup .sf-actions a:hover { text-decoration: underline; }
.set-filter-popup .sf-list { max-height: 200px; overflow-y: auto; }
.set-filter-popup .sf-list label { display: block; padding: 2px 0; font-size: 0.8rem; cursor: pointer; color: #aaa; }
.set-filter-popup .sf-list label:hover { background: #252525; color: #d4d4d4; }
.set-filter-popup .sf-apply { margin-top: 8px; text-align: right; }

/* Range filter popup */
.range-filter-popup { position: fixed; background: #1a1a1a; border: 1px solid #444; border-radius: 4px; box-shadow: 0 4px 20px rgba(0,0,0,0.6); z-index: 1000; padding: 10px; min-width: 160px; color: #d4d4d4; }
.range-filter-popup label { display: block; font-size: 0.78rem; margin-bottom: 3px; font-weight: 600; color: #14b8a6; }
.range-filter-popup input { width: 100%; padding: 3px 6px; border: 1px solid #444; border-radius: 3px; font-size: 0.8rem; margin-bottom: 6px; outline: none; background: #0d0d0d; color: #d4d4d4; font-family: inherit; }
.range-filter-popup input:focus { border-color: #14b8a6; }
.range-filter-popup .rf-apply { text-align: right; }

/* Table body */
tbody td { padding: 4px 6px; font-size: 0.8rem; border-bottom: 1px solid #1a1a1a; border-right: 1px solid #1a1a1a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #bbb; transition: background .1s ease; }
tbody td:last-child { border-right: none; }
tbody tr:nth-child(even) { background: #0f0f0f; }
tbody tr:nth-child(odd) { background: #111; }
tbody tr:hover td { background: #0a1a18 !important; }

.mp-yes { color: #14b8a6; font-weight: 700; text-align: center; }
.mp-no { color: #333; font-weight: 400; text-align: center; }

/* Numeric cells */
.num { text-align: right; font-variant-numeric: tabular-nums; }
.unit { font-size: 0.65em; color: #555; margin-left: 1px; }
.currency { color: #d4d4d4; }
.fee { color: #777; }
.dim { color: #555; }
.mp-full { color: #4ade80; font-weight: 700; }
.mp-mid { color: #14b8a6; }
.mp-low { color: #ef4444; }
.bundle-multi { color: #60a5fa; font-weight: 600; }

/* Light theme numeric overrides */
body.light .unit { color: #aaa; }
body.light .currency { color: #1a1a1a; }
body.light .fee { color: #888; }
body.light .dim { color: #aaa; }
body.light .mp-full { color: #16a34a; }
body.light .mp-mid { color: #0d9488; }
body.light .mp-low { color: #dc2626; }
body.light .mp-no { color: #ddd; }
body.light .bundle-multi { color: #2563eb; }

/* Pagination & Footer */
.footer-bar { padding: 6px 8px; border-top: 1px solid #2a2a2a; background: #0d0d0d; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50; }
.footer-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.footer-row.data-mgmt { margin-top: 6px; padding-top: 6px; border-top: 1px solid #1a1a1a; font-size: 0.78rem; }
.footer-info { font-size: 0.75rem; color: #666; }
.sep { color: #333; }
.footer-group { display: flex; align-items: center; gap: 4px; padding: 3px 8px; border: 1px solid #222; border-radius: 4px; background: #0a0a0a; }
.footer-group-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.5px; color: #555; font-weight: 700; margin-right: 2px; }
.footer-input { width: 45px; padding: 2px 4px; font-size: 0.75rem; border: 1px solid #333; border-radius: 3px; background: #1a1a1a; color: #d4d4d4; font-family: inherit; outline: none; }
.footer-input:focus { border-color: #14b8a6; }

.pagination { display: flex; align-items: center; justify-content: space-between; padding: 0; flex-wrap: wrap; gap: 6px; }
.pagination .page-info { font-size: 0.78rem; color: #666; }
.pagination .page-btns { display: flex; gap: 4px; align-items: center; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }
.pg-gap { width: 10px; }
.pagination .page-btns button { display: inline-flex; align-items: center; justify-content: center; height: 32px; min-width: 32px; padding: 0 8px; border: 1px solid #333; border-radius: 6px; background: #1a1a1a; color: #666; font-size: 13px; cursor: pointer; font-family: inherit; font-weight: 600; letter-spacing: 0.02em; }
.pagination .page-btns button:hover:not(:disabled) { background: #252525; color: #14b8a6; border-color: #14b8a6; }
.pagination .page-btns button:disabled { opacity: 0.15; cursor: not-allowed; }
.pagination .page-btns button.current { background: #14b8a6; color: #0d0d0d; border-color: #14b8a6; font-weight: 800; box-shadow: 0 0 10px rgba(20,184,166,0.4); }
.pagination .page-btns button.nav { min-width: 36px; font-size: 16px; color: #14b8a6; background: transparent; border-color: transparent; font-weight: 400; }
.pagination .page-btns button.nav:hover:not(:disabled) { border-color: #14b8a6; background: #0a1a18; }

/* Stats bar */
.stats-bar { display: flex; gap: 12px; align-items: center; font-size: 0.78rem; color: #666; flex-wrap: wrap; }
.stats-bar .stat { white-space: nowrap; }
.stats-bar .stat b { color: #14b8a6; font-size: 0.85rem; margin-right: 2px; }

/* Preset bar */
.preset-bar { display: flex; gap: 4px; align-items: center; }
.preset-select { min-width: 120px; }

/* Loading spinner */
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid #333; border-top-color: #14b8a6; border-radius: 50%; animation: spin .6s linear infinite; vertical-align: middle; margin-right: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Price source & profit coloring */
.src-buybox { color: #a78bfa; font-weight: 600; }
.src-amazon { color: #f59e0b; font-weight: 600; }
.src-fba { color: #ef4444; font-weight: 600; }
.src-fbm { color: #60a5fa; font-weight: 600; }
.pos { color: #4ade80; font-weight: 600; }
.neg { color: #ef4444; font-weight: 600; }

/* Note cells */
.note-cell, .field-cell { cursor: text; min-width: 80px; }
.note-cell:hover, .field-cell:hover { background: #0a1a18 !important; }
.review-cell { font-size: 0.9rem; color: #14b8a6; font-weight: 700; }
tr.reviewed-row td { background: #111a0f !important; border-left: none; }
tr.reviewed-row td:first-child { border-left: 3px solid #2ea043; }

/* False-positive rows (when visible) */
tr.fp-row td { opacity: 0.45; text-decoration: line-through; background: #1a0a0a !important; }
tr.fp-row td:first-child { border-left: 3px solid #ef4444; }
body.light tr.fp-row td { background: #fef2f2 !important; }
.fp-cell { font-size: 1rem; font-weight: 700; }

/* Empty state */
#emptyState { color: #555; }
#emptyState h2 { color: #14b8a6; }

/* Theme toggle */
.theme-toggle { background: none; border: 1px solid #444; border-radius: 3px; padding: 3px 8px; cursor: pointer; font-size: 0.85rem; color: #14b8a6; font-family: inherit; }
.theme-toggle:hover { background: #1a1a1a; }

/* ═══════ LIGHT THEME ═══════ */
body.light { background: #f5f5f0; color: #1a1a1a; }
body.light a { color: #0d9488; }
body.light a:hover { color: #0f766e; }
body.light ::selection { background: #0d9488; color: #fff; }
body.light ::-webkit-scrollbar-track { background: #e8e8e3; }
body.light ::-webkit-scrollbar-thumb { background: #bbb; }
body.light .tooltip-wrap .tooltip-icon { background: #ddd; color: #666; }
body.light .tooltip-wrap .tooltip-text { background: #333; color: #fff; }
body.light .tooltip-wrap .tooltip-text::after { border-top-color: #333; }
body.light .btn-primary { background: #0d9488; color: #fff; }
body.light .btn-primary:hover:not(:disabled) { background: #0f766e; }
body.light .btn-outline { border-color: #ccc; color: #555; }
body.light .btn-outline:hover:not(:disabled) { background: #eee; color: #0d9488; border-color: #0d9488; }
body.light .search-box { background: #fff; border-color: #ccc; color: #1a1a1a; }
body.light .search-box:focus { border-color: #0d9488; }
body.light select { background: #fff; border-color: #ccc; color: #1a1a1a; }
body.light select:focus { border-color: #0d9488; }
body.light .cols-dropdown-body { background: #fff; border-color: #ddd; }
body.light .cols-dropdown-body label { color: #555; }
body.light .cols-dropdown-body label:hover { background: #f5f5f0; color: #0d9488; }
body.light .table-wrap { background: #fff; border-color: #ddd; }
body.light thead tr:first-child th { background: #2d2d2d; color: #14b8a6; border-right-color: #444; border-bottom-color: #0d9488; }
body.light thead tr.filter-row th { background: #f0f0eb; border-bottom-color: #ddd; border-right-color: #ddd; }
body.light thead tr.filter-row th input { background: #fff; border-color: #ccc; color: #1a1a1a; }
body.light thead tr.filter-row th input::placeholder { color: #aaa; }
body.light .filter-btn { border-color: #ccc; color: #888; }
body.light .filter-btn:hover { background: #f5f5f0; color: #0d9488; border-color: #0d9488; }
body.light .filter-btn.active { border-color: #0d9488; color: #0d9488; }
body.light .set-filter-popup { background: #fff; border-color: #ddd; color: #1a1a1a; }
body.light .set-filter-popup .sf-search { background: #fff; border-color: #ccc; color: #1a1a1a; }
body.light .set-filter-popup .sf-actions a { color: #0d9488; }
body.light .set-filter-popup .sf-list label { color: #555; }
body.light .set-filter-popup .sf-list label:hover { background: #f5f5f0; }
body.light .range-filter-popup { background: #fff; border-color: #ddd; color: #1a1a1a; }
body.light .range-filter-popup label { color: #0d9488; }
body.light .range-filter-popup input { background: #fff; border-color: #ccc; color: #1a1a1a; }
body.light tbody td { border-bottom-color: #eee; border-right-color: #eee; color: #333; }
body.light tbody tr:nth-child(even) { background: #fafaf5; }
body.light tbody tr:nth-child(odd) { background: #fff; }
body.light tbody tr:hover td { background: #e6fffb !important; }
body.light .mp-yes { color: #0d9488; }
body.light .mp-no { color: #ccc; }
body.light .footer-bar { background: #f0f0eb; border-top-color: #ddd; }
body.light .footer-row.data-mgmt { border-top-color: #ddd; }
body.light .footer-info { color: #888; }
body.light .sep { color: #ccc; }
body.light .footer-group { border-color: #ddd; background: #f8f8f3; }
body.light .footer-group-label { color: #999; }
body.light .footer-input { background: #fff; border-color: #ccc; color: #1a1a1a; }
body.light .footer-input:focus { border-color: #0d9488; }
body.light .stats-bar { color: #888; }
body.light .stats-bar .stat b { color: #0d9488; }
body.light .pagination .page-info { color: #888; }
body.light .pagination .page-btns button { background: #fff; border-color: #ddd; color: #999; }
body.light .pagination .page-btns button:hover:not(:disabled) { background: #f5f5f0; color: #0d9488; border-color: #0d9488; }
body.light .pagination .page-btns button.current { background: #0d9488; color: #fff; border-color: #0d9488; box-shadow: 0 0 10px rgba(13,148,136,0.2); }
body.light .pagination .page-btns button.nav { color: #0d9488; background: transparent; border-color: transparent; }
body.light .pagination .page-btns button.nav:hover:not(:disabled) { border-color: #0d9488; background: #faf8f0; }
body.light .spinner { border-color: #ddd; border-top-color: #0d9488; }
body.light .src-buybox { color: #7c3aed; }
body.light .src-amazon { color: #d97706; }
body.light .src-fba { color: #dc2626; }
body.light .src-fbm { color: #2563eb; }
body.light .pos { color: #16a34a; }
body.light .neg { color: #dc2626; }
body.light .note-cell:hover, body.light .field-cell:hover { background: #e6fffb !important; }
body.light .review-cell { color: #0d9488; }
body.light tr.reviewed-row td { background: #f0f8ee !important; border-left: none; }
body.light tr.reviewed-row td:first-child { border-left: 3px solid #2ea043; }
body.light #emptyState { color: #888; }
body.light #emptyState h2 { color: #0d9488; }
body.light .theme-toggle { border-color: #ccc; color: #0d9488; }
body.light .theme-toggle:hover { background: #eee; }
body.light { caret-color: #333; }
body.light input, body.light select, body.light textarea { caret-color: #333; }

/* Responsive */
@media (max-width: 600px) {
  .stats-bar { gap: 6px; font-size: 0.72rem; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .search-box { width: 100%; }
}

/* Multi-match flag — amber left-border on first cell */
tr.multi-match td:first-child { border-left: 3px solid #f59e0b !important; }
tr.multi-match.sub-row td:first-child { border-left: 3px solid #f59e0b !important; }

/* Sub-row visual grouping */
tr.sub-row td { border-top: 1px dashed #222; }
body.light tr.sub-row td { border-top: 1px dashed #e5e7eb; }

/* Remaining hit zero — group fully reserved */
tr.remaining-zero td { background: #3a1a1a !important; }
tr.remaining-zero td:first-child { border-left: 3px solid #ef4444 !important; }
body.light tr.remaining-zero td { background: #fee2e2 !important; }

/* Profit calculated with missing FBA fee or weight — number is unreliable */
tr.profit-incomplete td { background: #3a2e1a !important; }
tr.profit-incomplete td:first-child { border-left: 3px solid #eab308 !important; }
body.light tr.profit-incomplete td { background: #fef3c7 !important; }

/* Click-to-copy barcodes in Match Barcodes column */
.bc-copy { cursor: pointer; padding: 1px 4px; border-radius: 3px; transition: background .1s, color .1s; }
.bc-copy:hover { background: rgba(20,184,166,0.18); color: #14b8a6; }
body.light .bc-copy:hover { background: rgba(13,148,136,0.18); color: #0d9488; }
.bc-copy.bc-copied { background: #14b8a6 !important; color: #0d0d0d !important; }
body.light .bc-copy.bc-copied { background: #0d9488 !important; color: #fff !important; }

/* Dimmed duplicate ASIN-level cells on sub-rows (kept visible for orientation) */
.dim-cell { opacity: 0.45; }
.dim-cell a { color: inherit; }

/* Row selection (click a row body to select/deselect) */
tr.selected-row td { background: rgba(20, 184, 166, 0.22) !important; box-shadow: inset 2px 0 0 #14b8a6; }
body.light tr.selected-row td { background: rgba(13, 148, 136, 0.16) !important; box-shadow: inset 2px 0 0 #0d9488; }

/* Custom-weight indicator (when user has overridden Keepa weight) */
td.weight-custom { color: #14b8a6; font-weight: 700; }
body.light td.weight-custom { color: #0d9488; }
td.weight-custom .wmark { opacity: 0.65; margin-right: 2px; font-size: 0.8em; }
