/* ── Reset & Variables ────────────────────────────────────────── */

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

:root {
    --bg: #0f0f23;
    --bg-card: #16213e;
    --bg-card-hover: #1a2847;
    --bg-input: #0d1b2a;
    --border: #1e3a5f;
    --border-hover: #2d5a8f;
    --text: #e0e6ed;
    --text-muted: #7a8ba0;
    --text-heading: #f0f4f8;
    --accent: #0ea5e9;
    --accent-hover: #38bdf8;
    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;
    --amazon: #ff9900;
    --ebay: #e53238;
    --aliexpress: #ff4747;
    --walmart: #0071dc;
    --bestbuy: #0046be;
    --flipkart: #f7d731;
    --radius: 8px;
    --radius-sm: 4px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --transition: 0.2s ease;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--accent-hover);
}

/* ── Header ──────────────────────────────────────────────────── */

.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0 8px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    color: var(--accent);
    font-size: 24px;
}

.logo-text {
    color: var(--text-heading);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background var(--transition);
}

.status-dot.online {
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
}

.status-dot.offline {
    background: var(--error);
}

.nav {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.nav-link {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
}

.nav-link:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
    color: var(--accent);
    background: rgba(14, 165, 233, 0.1);
}

/* ── Main ────────────────────────────────────────────────────── */

.main {
    flex: 1;
    padding: 24px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

/* ── Footer ──────────────────────────────────────────────────── */

.footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 12px 24px;
}

.footer-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    font-size: 12px;
    color: var(--text-muted);
}

/* ── Cards ───────────────────────────────────────────────────── */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-heading);
    margin-bottom: 16px;
}

.card-error {
    border-color: var(--error);
    background: rgba(239, 68, 68, 0.08);
}

/* ── Stats Grid ──────────────────────────────────────────────── */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

.stats-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-heading);
    font-family: var(--font-mono);
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* ── Forms & Inputs ──────────────────────────────────────────── */

.input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text);
    font-size: 14px;
    font-family: var(--font);
    outline: none;
    transition: border-color var(--transition);
    width: 100%;
}

.input:focus {
    border-color: var(--accent);
}

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

.select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%237a8ba0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
    cursor: pointer;
    width: auto;
    min-width: 140px;
}

.btn {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

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

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

.btn-secondary {
    background: transparent;
    border-color: var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    border-color: var(--border-hover);
    background: rgba(255, 255, 255, 0.05);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
}

/* ── Fetch Card ──────────────────────────────────────────────── */

.fetch-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.fetch-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.quick-paste {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.quick-label {
    font-size: 12px;
    color: var(--text-muted);
}

.input-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 10px 14px;
    background: rgba(14, 165, 233, 0.1);
    border: 1px solid rgba(14, 165, 233, 0.2);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-muted);
}

.hint-icon {
    width: 18px;
    height: 18px;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

/* ── Badges ──────────────────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border: none;
    cursor: pointer;
    transition: opacity var(--transition);
}

.badge:hover {
    opacity: 0.85;
}

.badge-amazon {
    background: rgba(255, 153, 0, 0.15);
    color: var(--amazon);
}

.badge-ebay {
    background: rgba(229, 50, 56, 0.15);
    color: var(--ebay);
}

.badge-aliexpress {
    background: rgba(255, 71, 71, 0.15);
    color: var(--aliexpress);
}

.badge-walmart {
    background: rgba(0, 113, 220, 0.15);
    color: var(--walmart);
}

.badge-bestbuy {
    background: rgba(0, 70, 190, 0.15);
    color: var(--bestbuy);
}

.badge-flipkart {
    background: rgba(247, 215, 49, 0.15);
    color: var(--flipkart);
}

.badge-success {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.badge-error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.badge-cached {
    background: rgba(14, 165, 233, 0.15);
    color: var(--accent);
}

.badge-fetched {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.badge-discount {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.badge-in_stock {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.badge-out_of_stock {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.badge-limited_stock {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.badge-cannot_ship {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

/* ── Tables ──────────────────────────────────────────────────── */

.table-wrap {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 12px;
    border-bottom: 1px solid rgba(30, 58, 95, 0.4);
    font-size: 13px;
    vertical-align: middle;
}

.table tbody tr {
    transition: background var(--transition);
    cursor: pointer;
}

.table tbody tr:hover {
    background: var(--bg-card-hover);
}

.th-img {
    width: 50px;
}

.table-img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    background: var(--bg-input);
}

.table-title {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-heading);
}

.table-price {
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--success);
}

/* ── Pagination ──────────────────────────────────────────────── */

.pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    padding: 16px 0 0;
}

.page-btn {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition);
}

.page-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.page-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ── Product Detail ──────────────────────────────────────────── */

.detail-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.detail-actions {
    display: flex;
    gap: 8px;
}

.detail-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 24px;
}

.main-image {
    width: 100%;
    height: 280px;
    object-fit: contain;
    border-radius: var(--radius);
    background: var(--bg-input);
}

.detail-title {
    font-size: 20px;
    color: var(--text-heading);
    margin-bottom: 8px;
    line-height: 1.4;
}

.detail-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.detail-price-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.detail-price {
    font-size: 28px;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--success);
}

.detail-original-price {
    font-size: 16px;
    color: var(--text-muted);
    text-decoration: line-through;
}

.detail-field {
    padding: 6px 0;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-field strong {
    color: var(--text-muted);
    min-width: 100px;
}

/* ── Confidence Bar ──────────────────────────────────────────── */

.confidence-bar-wrap {
    width: 120px;
    height: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
}

.confidence-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* ── Image Gallery ───────────────────────────────────────────── */

.image-gallery {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.gallery-thumb {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color var(--transition);
    background: var(--bg-input);
}

.gallery-thumb:hover,
.gallery-thumb.active {
    border-color: var(--accent);
}

/* ── Description & Specs ─────────────────────────────────────── */

.description-text {
    font-size: 13px;
    color: var(--text);
    line-height: 1.8;
    max-height: 300px;
    overflow-y: auto;
}

.specs-table {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 1px;
}

.spec-key {
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-muted);
    background: var(--bg-input);
    font-weight: 500;
}

.spec-value {
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text);
    background: rgba(13, 27, 42, 0.4);
}

/* ── Collapsible Sections ────────────────────────────────────── */

.collapsible {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}

.collapsible:hover {
    color: var(--accent);
}

.toggle-icon {
    font-size: 10px;
    transition: transform var(--transition);
}

.toggle-icon.open {
    transform: rotate(90deg);
}

/* ── JSON Block ──────────────────────────────────────────────── */

.json-block {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text);
    overflow-x: auto;
    max-height: 400px;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ── Sources Page ────────────────────────────────────────────── */

.source-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: border-color var(--transition);
}

.source-card:hover {
    border-color: var(--border-hover);
}

.source-info h3 {
    font-size: 16px;
    color: var(--text-heading);
    margin-bottom: 4px;
}

.source-stats {
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    gap: 16px;
    margin-top: 4px;
}

.source-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

/* ── Filters ─────────────────────────────────────────────────── */

.filters-card {
    margin-bottom: 16px;
}

.filters-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.filters-row .input:first-child {
    flex: 1;
    min-width: 200px;
}

/* ── Loading & Spinner ───────────────────────────────────────── */

.loading {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px;
    color: var(--text-muted);
    justify-content: center;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* ── Result Card (Dashboard) ─────────────────────────────────── */

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

.result-header .card-title {
    margin-bottom: 0;
}

.product-card {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 16px;
    margin-top: 16px;
}

.product-card-image {
    width: 120px;
    height: 120px;
    object-fit: contain;
    border-radius: var(--radius);
    background: var(--bg-input);
}

.product-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-heading);
    margin-bottom: 6px;
}

.product-card-price {
    font-size: 20px;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--success);
    margin-bottom: 4px;
}

.product-card-meta {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* ── Resolve Result ──────────────────────────────────────────── */

.resolve-grid {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 4px 12px;
    font-size: 13px;
}

.resolve-grid dt {
    color: var(--text-muted);
    font-weight: 500;
}

.resolve-grid dd {
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 13px;
}

/* ── Recent Activity ─────────────────────────────────────────── */

.activity-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(30, 58, 95, 0.3);
    font-size: 13px;
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-time {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 12px;
    min-width: 60px;
}

.activity-product {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}

.activity-duration {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 12px;
}

/* ── Modal ───────────────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}

.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.2s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-heading);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color var(--transition);
}

.modal-close:hover {
    color: var(--error);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(80vh - 60px);
}

.log-detail-grid {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 12px 16px;
    font-size: 13px;
}

.log-detail-label {
    color: var(--text-muted);
    font-weight: 500;
}

.log-detail-value {
    color: var(--text);
    word-break: break-word;
}

.log-detail-value.mono {
    font-family: var(--font-mono);
    font-size: 12px;
}

.log-detail-value a {
    word-break: break-all;
}

.log-error-box {
    margin-top: 16px;
    padding: 12px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
}

.log-error-box-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--error);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.log-error-box-content {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.6;
}

/* ── Scrape Logs ─────────────────────────────────────────────── */

.log-row {
    transition: background var(--transition);
    cursor: pointer;
}

.log-row:hover {
    background: var(--bg-card-hover);
}

.log-row.log-success {
    border-left: 3px solid var(--success);
}

.log-row.log-failed {
    border-left: 3px solid var(--error);
}

.log-row.log-cached {
    border-left: 3px solid var(--accent);
}

.log-row.log-pending {
    border-left: 3px solid var(--warning);
}

.log-time {
    font-size: 12px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    white-space: nowrap;
}

.log-product {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 12px;
}

.log-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.log-status.status-success {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.log-status.status-failed {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.log-status.status-cached {
    background: rgba(14, 165, 233, 0.15);
    color: var(--accent);
}

.log-status.status-pending {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.status-icon {
    font-size: 12px;
}

.log-time-val {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
}

.log-error {
    max-width: 250px;
    font-size: 12px;
}

.error-type {
    display: inline-block;
    padding: 2px 6px;
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    margin-right: 6px;
}

.error-msg {
    color: var(--text-muted);
    font-size: 12px;
}

/* ── Page Title ──────────────────────────────────────────────── */

.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-heading);
    margin-bottom: 20px;
}

/* ── Utility ─────────────────────────────────────────────────── */

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

.text-center {
    text-align: center;
}

.text-success {
    color: var(--success);
}

.text-error {
    color: var(--error);
}

/* ── Compare Page ────────────────────────────────────────────── */

.compare-page .search-card {
    margin-bottom: 24px;
}

.search-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.search-input {
    font-size: 16px;
    padding: 14px 18px;
}

.search-options {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.btn-search {
    align-self: flex-start;
    padding: 12px 32px;
    font-size: 15px;
}

.loading-card {
    text-align: center;
    padding: 40px;
}

.loading-sources {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 16px;
}

.loading-source {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-muted);
}

.spinner-small {
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.stats-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* Recommendation Card */
.recommendation-card {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.1) 0%, rgba(14, 165, 233, 0.1) 100%);
    border-color: var(--success);
    margin-bottom: 16px;
}

.recommendation-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.recommendation-badge {
    background: var(--success);
    color: #fff;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.recommendation-header h3 {
    font-size: 16px;
    color: var(--text-heading);
    margin: 0;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recommendation-body {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.recommendation-main {
    display: flex;
    gap: 20px;
    flex: 1;
}

.recommendation-image {
    width: 120px;
    height: 120px;
    object-fit: contain;
    background: var(--bg-input);
    border-radius: var(--radius);
}

.recommendation-details {
    flex: 1;
}

.recommendation-price {
    font-size: 32px;
    font-weight: 700;
    color: var(--success);
    font-family: var(--font-mono);
    margin-bottom: 8px;
}

.recommendation-source {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.recommendation-reasons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.reason-tag {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.recommendation-savings {
    background: var(--bg-input);
    padding: 16px;
    border-radius: var(--radius);
    min-width: 200px;
}

.savings-item {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
}

.savings-label {
    color: var(--text-muted);
}

.savings-value {
    color: var(--success);
    font-weight: 600;
    font-family: var(--font-mono);
}

/* Compare Table */
.compare-table .table-title {
    max-width: 250px;
    position: relative;
}

.best-deal-row {
    background: rgba(34, 197, 94, 0.08);
}

.best-deal-row:hover {
    background: rgba(34, 197, 94, 0.12);
}

.best-badge {
    display: inline-block;
    background: var(--success);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    margin-right: 8px;
    vertical-align: middle;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.small {
    font-size: 11px;
}

/* Source Status */
.source-status-card {
    margin-top: 16px;
}

.source-status-grid {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.source-status-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--border);
}

.source-status-item.success,
.source-status-item.source-ok {
    border-left-color: var(--success);
}

.source-status-item.failed,
.source-status-item.source-error {
    border-left-color: var(--error);
}

.source-status-icon {
    font-size: 14px;
    font-weight: bold;
}

.source-ok .source-status-icon {
    color: var(--success);
}

.source-error .source-status-icon {
    color: var(--error);
}

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

.source-error .source-status-info {
    color: var(--error);
}

.source-error-msg {
    display: block;
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Empty/Error States */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-icon {
    font-size: 48px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.empty-state h3 {
    color: var(--text-heading);
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-muted);
}

.error-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.error-icon {
    width: 32px;
    height: 32px;
    background: var(--error);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
}

/* ── Responsive ──────────────────────────────────────────────── */

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .stats-grid-3 {
        grid-template-columns: 1fr;
    }

    .detail-layout {
        grid-template-columns: 1fr;
    }

    .filters-row {
        flex-direction: column;
    }

    .filters-row .input,
    .filters-row .select {
        width: 100%;
    }

    .fetch-actions {
        flex-wrap: wrap;
    }

    .nav {
        overflow-x: auto;
    }

    .detail-topbar {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .specs-table {
        grid-template-columns: 1fr;
    }

    .stats-grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .recommendation-body {
        flex-direction: column;
    }

    .recommendation-main {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .recommendation-savings {
        width: 100%;
    }

    .recommendation-reasons {
        justify-content: center;
    }

    .source-status-grid {
        flex-direction: column;
    }
}
