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

:root {
    --navy: #061b3a;
    --navy-2: #0d2a53;
    --orange: #f45113;
    --orange-dark: #cf3c08;
    --green: #07883e;
    --green-soft: #e8f7ed;
    --amber: #bd5a00;
    --red: #b42318;
    --bg: #f5f7fa;
    --surface: #fff;
    --surface-2: #f8fafc;
    --text: #0c1f3b;
    --muted: #627085;
    --link: #1556b0;
    --border: #ccd4df;
    --border-soft: #e3e8ef;
    --shadow: 0 10px 30px rgba(6, 27, 58, .08);
    --primary-color: var(--orange);
    --primary-dark: var(--orange-dark);
    --success-color: var(--green);
    --danger-color: var(--red);
    --warning-color: #d97706;
    --background: var(--bg);
    --text-primary: var(--text);
    --text-secondary: var(--muted);
}

[data-theme="dark"] {
    --bg: #071323;
    --surface: #0d2039;
    --surface-2: #102744;
    --text: #f5f8fc;
    --muted: #aab7c8;
    --link: #8ab8ff;
    --border: #31445d;
    --border-soft: #223852;
    --green-soft: rgba(18, 137, 68, .16);
    --shadow: 0 12px 32px rgba(0, 0, 0, .3);
}

html { color-scheme: light; scroll-behavior: smooth; }
[data-theme="dark"] { color-scheme: dark; }
body {
    min-width: 320px;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 Inter, system-ui, sans-serif;
    transition: background .2s, color .2s;
}
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
    outline: 3px solid rgba(244, 81, 19, .38);
    outline-offset: 3px;
}
.hidden { display: none !important; }

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    height: 68px;
    background: var(--navy);
    color: #fff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .14);
}
.header-inner {
    width: min(1380px, calc(100% - 48px));
    height: 100%;
    margin: auto;
    display: flex;
    align-items: center;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-right: 34px;
    color: #fff;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -.04em;
    text-decoration: none;
}
.brand-mark { width: 38px; height: 38px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; }
.brand-mark .brand-signal { stroke: var(--orange); stroke-width: 4; }
.main-nav { display: flex; align-self: stretch; gap: 8px; }
.main-nav a {
    position: relative;
    display: grid;
    place-items: center;
    padding: 0 18px;
    color: #d7e0ec;
    font-weight: 600;
    text-decoration: none;
}
.main-nav a:hover, .main-nav a.active { color: #fff; }
.main-nav a.active::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 18px;
    right: 18px;
    height: 4px;
    background: var(--orange);
}
.theme-toggle {
    width: 42px;
    height: 42px;
    margin-left: auto;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 10px;
    background: transparent;
    cursor: pointer;
}
.theme-toggle:hover { background: rgba(255, 255, 255, .1); }
.theme-toggle svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.sun-icon { display: none; }
[data-theme="dark"] .sun-icon { display: block; }
[data-theme="dark"] .moon-icon { display: none; }

.page-shell {
    width: min(1380px, calc(100% - 48px));
    min-height: calc(100vh - 130px);
    margin: 0 auto;
    padding: 34px 0 64px;
}
.search-hero h1 {
    max-width: 980px;
    color: var(--navy);
    font: 800 clamp(42px, 5vw, 68px)/.98 "Barlow Condensed", sans-serif;
    letter-spacing: -.025em;
}
[data-theme="dark"] .search-hero h1 { color: var(--text); }
.search-hero > p { margin-top: 8px; color: var(--muted); font-size: 18px; }
.search-box { display: flex; gap: 12px; margin-top: 20px; }
.search-input-wrap { position: relative; flex: 1; }
.search-input-wrap svg {
    position: absolute;
    left: 18px;
    top: 50%;
    width: 23px;
    transform: translateY(-50%);
    fill: none;
    stroke: var(--muted);
    stroke-width: 2;
}
#searchInput, #urlInput {
    width: 100%;
    min-height: 60px;
    padding: 0 50px;
    border: 1px solid var(--border);
    border-radius: 9px;
    outline: 0;
    background: var(--surface);
    color: var(--text);
    font-size: 17px;
    box-shadow: 0 1px 2px rgba(6, 27, 58, .04);
}
#searchInput:focus, #urlInput:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(244, 81, 19, .14); }
.btn-primary {
    min-height: 54px;
    padding: 0 34px;
    border: 0;
    border-radius: 9px;
    background: var(--orange);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s, transform .15s;
}
.search-box .btn-primary { min-width: 200px; font-size: 16px; }
.btn-primary:hover { background: var(--orange-dark); transform: translateY(-1px); }
.search-examples { display: flex; flex-wrap: wrap; gap: 10px 20px; margin: 12px 2px 22px; color: var(--muted); font-size: 13px; }
.search-examples button { border: 0; background: none; color: var(--link); cursor: pointer; font-weight: 600; }
[data-theme="dark"] .search-examples button { color: #74a8ef; }
.search-examples button:hover { text-decoration: underline; }

.filter-panel {
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: 0 2px 8px rgba(6, 27, 58, .04);
}
.filter-icon { width: 64px; display: grid; place-items: center; border-right: 1px solid var(--border-soft); }
.filter-icon svg { width: 22px; fill: none; stroke: var(--text); stroke-width: 2; stroke-linecap: round; }
.filters { flex: 1; display: flex; align-items: end; gap: 10px; padding: 13px 16px; }
.filter-group { position: relative; min-width: 130px; flex: 1; }
.filter-group label {
    position: absolute;
    z-index: 1;
    top: -7px;
    left: 10px;
    padding: 0 4px;
    background: var(--surface);
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
}
.filter-group select {
    width: 100%;
    height: 44px;
    padding: 0 30px 0 12px;
    border: 1px solid var(--border);
    border-radius: 7px;
    outline: 0;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}
.filter-group select:focus { border-color: var(--orange); }
.stock-filter { min-width: 130px; height: 44px; display: flex; align-items: center; gap: 8px; cursor: pointer; white-space: nowrap; }
.stock-filter input { width: 17px; height: 17px; accent-color: var(--orange); }
.sort-group { max-width: 170px; padding-left: 12px; border-left: 1px solid var(--border-soft); }
.clear-filters { height: 44px; padding: 0 10px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-weight: 600; }
.clear-filters:hover { color: var(--orange); }

.error-message, .cache-indicator, .store-progress-bar {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: 8px;
    font-weight: 600;
}
.error-message { border: 1px solid #f1b4ad; background: #fff0ee; color: var(--red); }
.cache-indicator { border: 1px solid #efd094; background: #fff8e8; color: #8a4b00; text-align: center; }
[data-theme="dark"] .error-message, [data-theme="dark"] .cache-indicator { background: var(--surface-2); }

.loading {
    margin-top: 18px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
}
.loading-head, .loading-head > div { display: flex; align-items: center; gap: 10px; }
.loading-head { justify-content: space-between; }
.spinner, .store-status-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--orange);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn-cancel { border: 0; background: transparent; color: var(--red); font-weight: 700; cursor: pointer; }
.store-progress-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.store-progress-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    font-size: 12px;
}
.store-progress-item.active { border-color: var(--orange); color: var(--orange); }
.store-progress-item.done { border-color: #9ad4ae; color: var(--green); }
.store-progress-item.error { border-color: #efaaa3; color: var(--red); }
.store-progress-item.disabled { opacity: .55; }
.store-status-icon.waiting::after { content: "•"; }
.store-status-check { font-weight: 800; }
.store-status-error { font-weight: 900; }
.store-count { opacity: .8; }
.store-progress-bar { display: flex; gap: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); }
.store-progress-bar-label { color: var(--orange); }

.results-area { margin-top: 20px; }
.results-summary {
    padding: 0 4px 12px;
    color: var(--navy);
    font-size: 17px;
    font-weight: 800;
}
[data-theme="dark"] .results-summary { color: var(--text); }
.results-section {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--shadow);
}
.product-card {
    display: grid;
    grid-template-columns: minmax(430px, 1.35fr) minmax(180px, .45fr) minmax(470px, 1.4fr);
    min-height: 230px;
    border-bottom: 1px solid var(--border);
}
.product-card:last-child { border-bottom: 0; }
.product-header { display: grid; grid-template-columns: 250px 1fr; gap: 20px; padding: 18px; }
.product-image {
    position: relative;
    height: 190px;
    overflow: hidden;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--surface-2);
}
.product-image img { width: 100%; height: 100%; object-fit: contain; mix-blend-mode: multiply; }
[data-theme="dark"] .product-image img { mix-blend-mode: normal; }
.product-image-placeholder { display: grid; place-items: center; width: 100%; height: 100%; color: var(--muted); }
.product-image-placeholder svg { width: 70px; fill: none; stroke: currentColor; stroke-width: 1.5; opacity: .35; }
.favorite-button {
    position: absolute;
    top: 9px;
    right: 9px;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    cursor: pointer;
}
.favorite-button svg { width: 18px; fill: none; stroke: var(--text); stroke-width: 1.8; }
.favorite-button.active svg { fill: var(--orange); stroke: var(--orange); }
.product-info { min-width: 0; padding-top: 5px; }
.product-title { color: var(--text); font-size: 17px; line-height: 1.35; }
.product-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 13px; }
.meta-badge {
    display: inline-flex;
    padding: 3px 7px;
    border: 1px solid #d3dbe6;
    border-radius: 5px;
    background: var(--surface-2);
    color: #35506e;
    font-size: 11px;
    font-weight: 600;
}
[data-theme="dark"] .meta-badge { color: var(--muted); border-color: var(--border); }
.product-code { margin-top: 14px; color: var(--muted); font-size: 12px; }

.best-price-highlight {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 20px;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
}
.best-price-label { width: max-content; padding: 3px 7px; border-radius: 4px; background: var(--green-soft); color: var(--green); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.best-price-amount { margin-top: 8px; color: var(--green); font-size: 30px; font-weight: 800; letter-spacing: -.04em; }
.best-price-store { margin-top: 2px; color: var(--muted); font-size: 12px; }
.price-savings { margin-top: 8px; color: var(--green); font-size: 12px; font-weight: 700; }

.price-comparison { display: flex; flex-direction: column; }
.price-comparison-header { padding: 12px 18px; border-bottom: 1px solid var(--border-soft); color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.store-price-card {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 90px 100px 44px;
    align-items: center;
    gap: 10px;
    min-height: 55px;
    padding: 9px 16px;
    border-bottom: 1px solid var(--border-soft);
}
.store-price-card:last-child { border-bottom: 0; }
.store-price-card.best-price { background: rgba(7, 136, 62, .035); }
.store-header { min-width: 0; display: flex; align-items: center; gap: 9px; }
.store-icon {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px solid var(--border-soft);
    border-radius: 7px;
    background: #fff;
}
.store-icon img {
    width: 22px;
    height: 22px;
    object-fit: contain;
}
.store-icon-fallback {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    background: var(--navy-2);
    color: #fff;
    font-size: 9px;
    font-weight: 800;
}
.store-name { overflow: hidden; color: var(--text); font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.store-price { color: var(--link); font-size: 13px; font-weight: 800; }
.store-price-card.best-price .store-price { color: var(--green); }
.stock-status { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; }
.stock-indicator { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.stock-indicator.in-stock { background: var(--green); }
.stock-indicator.out-of-stock { background: var(--red); }
.stock-indicator.preorder { background: var(--amber); }
.stock-indicator.backorder { background: var(--amber); }
.store-link {
    width: 36px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--link);
    text-decoration: none;
}
.store-link:hover { border-color: var(--orange); color: var(--orange); }
.store-link svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 2; }

.pagination-container { margin-top: 20px; padding: 18px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); text-align: center; }
.pagination-info { margin-bottom: 10px; color: var(--muted); font-size: 12px; }
.pagination-controls, .page-numbers { display: flex; align-items: center; justify-content: center; gap: 6px; }
.pagination-btn, .page-number {
    min-width: 38px;
    height: 38px;
    padding: 0 11px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}
.page-number.active, .pagination-btn:hover:not(:disabled), .page-number:hover { border-color: var(--navy); background: var(--navy); color: #fff; }
.pagination-btn:disabled { opacity: .4; cursor: not-allowed; }
.page-ellipsis { color: var(--muted); }
.no-results { padding: 70px 20px; text-align: center; color: var(--muted); }
.no-results svg { width: 70px; fill: none; stroke: currentColor; stroke-width: 2; opacity: .45; }
.no-results h2 { margin-top: 14px; color: var(--text); }
.no-results p { margin-top: 5px; }

.site-footer {
    border-top: 6px double var(--border);
    background: var(--surface);
    color: var(--muted);
    font-size: 12px;
}
.site-footer > div { width: min(1380px, calc(100% - 48px)); margin: auto; padding: 20px 0; display: flex; justify-content: space-between; gap: 20px; }
.site-footer a { color: var(--link); font-weight: 600; }

/* URL comparison page compatibility */
.container { width: min(1180px, calc(100% - 48px)); margin: auto; padding: 32px 0 64px; }
.header { margin-bottom: 18px; }
.header-content { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.header h1 { color: var(--navy); font: 800 48px/1 "Barlow Condensed", sans-serif; }
[data-theme="dark"] .header h1 { color: var(--text); }
.header p { margin-top: 6px; color: var(--muted); }
.page-nav { margin-bottom: 16px; }
.nav-link { color: var(--link); font-weight: 700; }
.url-page .search-section, .url-page .product-info-section, .url-page .result-card, .url-page .results-summary {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--shadow);
}
.url-page .search-section, .url-page .product-info-section { padding: 24px; margin-bottom: 20px; }
.url-search-box { display: grid; gap: 12px; }
.url-label { font-weight: 700; }
.url-search-box #urlInput { padding: 0 18px; }
.supported-stores { margin-top: 14px; color: var(--muted); font-size: 12px; }
.product-details { display: flex; gap: 24px; }
.original-product-image {
    width: 220px;
    height: 190px;
    flex: 0 0 220px;
    border-radius: 8px;
    background: var(--surface-2);
    object-fit: contain;
}
.product-text h4 { font-size: 20px; }
.original-price, .original-store { margin-top: 10px; color: var(--muted); }
.btn-secondary { display: inline-block; margin-top: 12px; padding: 9px 14px; border-radius: 7px; background: var(--navy); color: #fff; text-decoration: none; }
.url-page .search-section { margin-top: 24px; }
.url-page .loading { display: flex; align-items: center; gap: 12px; }
.url-page .loading .spinner { flex: 0 0 auto; }
.url-page .results-summary { margin-bottom: 16px; padding: 20px; color: var(--text); }
.container .results-section, .url-page .results-section { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; overflow: visible; border: 0; background: transparent; box-shadow: none; }
.result-card { position: relative; min-width: 0; padding: 18px; }
.result-image { height: 190px; display: grid; place-items: center; border-radius: 8px; background: var(--surface-2); overflow: hidden; }
.result-image img { width: 100%; height: 100%; object-fit: contain; }
.no-image { color: var(--muted); font-size: 13px; }
.result-content { margin-top: 14px; }
.result-header { display: flex; justify-content: space-between; gap: 12px; }
.product-name { min-width: 0; overflow-wrap: anywhere; font-size: 16px; }
.store-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex: 0 0 auto;
    padding: 3px 7px 3px 4px;
    border: 1px solid color-mix(in srgb, var(--store-color) 35%, var(--border));
    border-radius: 6px;
    background: color-mix(in srgb, var(--store-color) 9%, var(--surface));
    color: var(--text);
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
}
.store-badge img {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    background: #fff;
    object-fit: contain;
}
.result-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-soft); }
.price-section { display: flex; flex-direction: column; }
.price { color: var(--green); font-size: 24px; font-weight: 800; }
.price.unavailable { color: var(--muted); font-size: 16px; }
.savings { color: var(--green); font-size: 11px; }
.more-expensive { color: var(--red); font-size: 11px; }
.view-product { width: 100%; margin-top: 14px; display: grid; place-items: center; text-decoration: none; }
.best-price-badge, .original-badge { position: absolute; top: 10px; right: 10px; z-index: 2; padding: 4px 8px; border-radius: 5px; background: var(--green); color: #fff; font-size: 10px; font-weight: 800; }
.original-badge { background: var(--navy); }
.summary-stats { display: flex; flex-wrap: wrap; gap: 24px; }
.stat { display: flex; flex-direction: column; }
.stat-label { color: var(--muted); font-size: 11px; }
.stat-value { font-size: 22px; font-weight: 800; }
.best-deal { margin-top: 12px; color: var(--green); }
.report-issues-btn { display: none; }

@media (max-width: 1120px) {
    .filters { flex-wrap: wrap; }
    .filter-group { flex: 1 1 150px; }
    .filter-icon { align-self: stretch; }
    .product-card { grid-template-columns: minmax(380px, 1.1fr) 190px minmax(380px, 1fr); }
    .product-header { grid-template-columns: 190px 1fr; }
}

@media (max-width: 1020px) {
    .product-card { grid-template-columns: minmax(0, 1fr) 190px; }
    .price-comparison { grid-column: 1 / -1; border-top: 1px solid var(--border); }
    .best-price-highlight { border-right: 0; }
}

@media (max-width: 900px) {
    .header-inner, .page-shell, .site-footer > div { width: min(100% - 28px, 720px); }
    .brand { padding-right: 18px; }
    .main-nav { gap: 2px; }
    .main-nav a { padding: 0 12px; font-size: 13px; }
    .main-nav a.active::after { left: 12px; right: 12px; }
    .page-shell { padding-top: 26px; }
    .search-hero h1 { font-size: 48px; }
    .filter-icon { display: none; }
    .product-header { grid-template-columns: 190px 1fr; }
}

@media (max-width: 640px) {
    .site-header { height: 60px; }
    .brand { padding-right: 8px; font-size: 21px; }
    .brand-mark { width: 33px; }
    .main-nav { margin-left: auto; }
    .main-nav a { padding: 0 8px; font-size: 12px; }
    .main-nav a.active { display: none; }
    .theme-toggle { width: 38px; height: 38px; margin-left: 2px; }
    .page-shell, .container { width: calc(100% - 24px); padding-top: 22px; }
    .search-hero h1 { font-size: clamp(38px, 11vw, 42px); }
    .search-hero > p { font-size: 15px; }
    .search-box { flex-direction: column; }
    .search-box .btn-primary { width: 100%; min-height: 52px; }
    #searchInput { min-height: 54px; font-size: 15px; }
    .search-examples { gap: 7px 12px; }
    .filter-panel { display: block; }
    .filters { display: grid; grid-template-columns: 1fr 1fr; padding: 14px; }
    .filter-group, .sort-group { min-width: 0; max-width: none; padding-left: 0; border-left: 0; }
    .stock-filter { min-width: 0; }
    .product-card { display: block; }
    .product-header { grid-template-columns: 1fr; }
    .product-image { height: 210px; }
    .best-price-highlight { padding: 16px 18px; border: 0; border-top: 1px solid var(--border); }
    .price-comparison { border-top: 1px solid var(--border); }
    .store-price-card { grid-template-columns: 1fr 72px 76px 36px; gap: 6px; padding: 9px 10px; }
    .store-name { max-width: 125px; }
    .store-icon { width: 24px; height: 24px; flex-basis: 24px; }
    .store-icon img { width: 19px; height: 19px; }
    .site-footer > div { width: calc(100% - 24px); flex-direction: column; }
    .container .results-section, .url-page .results-section { grid-template-columns: 1fr; }
    .header h1 { font-size: 38px; }
    .product-details { flex-direction: column; }
    .original-product-image { width: 100%; height: 220px; flex-basis: auto; }
    .result-header { flex-direction: column; align-items: flex-start; }
    .store-badge { max-width: 100%; white-space: normal; }
    .summary-stats { gap: 16px 24px; }
}

@media (max-width: 360px) {
    .filters { grid-template-columns: 1fr; }
    .store-price-card {
        grid-template-columns: minmax(0, 1fr) auto 36px;
        grid-template-areas:
            "store price link"
            "stock stock stock";
        row-gap: 4px;
    }
    .store-header { grid-area: store; }
    .store-price { grid-area: price; }
    .stock-status { grid-area: stock; padding-left: 33px; }
    .store-link { grid-area: link; }
    .store-name { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
