/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.5;
}
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Auth Pages */
.auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: #f0f4f8;
}
.auth-container {
    background: #fff;
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    width: 100%;
    max-width: 400px;
}
.auth-container h1 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
    color: #1a1a1a;
}
.auth-container h2 {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 1.5rem;
    font-weight: 400;
}
.auth-container label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
    font-size: 0.9rem;
}
.auth-container input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.95rem;
    margin-bottom: 1rem;
}
.auth-container input:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,0.15); }
.auth-container button {
    width: 100%;
    padding: 0.7rem;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    font-weight: 500;
}
.auth-container button:hover { background: #1d4ed8; }
.auth-link { text-align: center; margin-top: 1rem; font-size: 0.9rem; color: #666; }
.error-msg {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
    padding: 0.6rem 0.75rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* Top Bar */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 100;
}
.logo { font-weight: 700; font-size: 1.2rem; color: #1a1a1a; }
.top-bar-right { display: flex; align-items: center; gap: 0.75rem; }
.username { font-size: 0.9rem; color: #666; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    font-weight: 500;
    transition: background 0.15s;
}
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-outline { background: transparent; border: 1px solid #d1d5db; color: #333; }
.btn-outline:hover { background: #f3f4f6; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Container */
.container { max-width: 900px; margin: 0 auto; padding: 1.5rem; }

/* Categories */
.categories-section {
    background: #fff;
    padding: 1.25rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    border: 1px solid #e5e7eb;
}
.categories-section h3 { font-size: 0.95rem; margin-bottom: 0.75rem; color: #555; }
.category-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.75rem; }
.chip {
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    border: 1px solid #d1d5db;
    background: #fff;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
    color: #555;
}
.chip:hover { border-color: #2563eb; color: #2563eb; }
.chip.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.custom-category { display: flex; gap: 0.5rem; }
.custom-category input {
    flex: 1;
    padding: 0.4rem 0.6rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.85rem;
}

/* Input Section */
.input-section {
    background: #fff;
    padding: 1.25rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    border: 1px solid #e5e7eb;
}
.tabs { display: flex; gap: 0; margin-bottom: 1rem; border-bottom: 2px solid #e5e7eb; }
.tab {
    padding: 0.5rem 1rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    color: #666;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-weight: 500;
}
.tab:hover { color: #333; }
.tab.active { color: #2563eb; border-bottom-color: #2563eb; }
.tab-content { display: none; }
.tab-content.active { display: block; }
.tab-content textarea,
.tab-content input[type="url"] {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    font-family: inherit;
}
.tab-content textarea { resize: vertical; }
.tab-content input:focus,
.tab-content textarea:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,0.15); }
.price-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; }
.price-row label { font-size: 0.9rem; font-weight: 500; white-space: nowrap; }
.price-row input { width: 150px; padding: 0.4rem 0.6rem; border: 1px solid #d1d5db; border-radius: 6px; font-size: 0.9rem; }

/* Auto-Scout */
.autoscout-controls { margin-bottom: 0.75rem; }
.autoscout-controls label { display: block; font-size: 0.9rem; font-weight: 500; margin-bottom: 0.35rem; }
.metro-select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    background: #fff;
    margin-bottom: 0.5rem;
}
.metro-select:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,0.15); }
.autoscout-hint { font-size: 0.8rem; color: #888; margin: 0; }

/* Progress Bar */
.progress-bar-container { margin-top: 1rem; }
.progress-bar {
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}
.progress-fill {
    height: 100%;
    background: #2563eb;
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}
.progress-text { font-size: 0.85rem; color: #666; }

/* Cost Stats */
.cost-stats {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 6px;
}
.cost-stats:empty { display: none; }
.cost-stats strong { color: #0369a1; }

/* Dedup Stats */
.dedup-stats {
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 0.75rem;
}
.dedup-stats:empty { display: none; }

/* Results */
.results-section {
    background: #fff;
    padding: 1.25rem;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
}
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.results-header h3 { font-size: 1rem; color: #555; }
.filter-bar { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.filter-btn {
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    border: 1px solid #d1d5db;
    background: #fff;
    font-size: 0.8rem;
    cursor: pointer;
    color: #555;
}
.filter-btn:hover { border-color: #2563eb; }
.filter-btn.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.filter-input {
    width: 100px;
    padding: 0.25rem 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.8rem;
}

/* Result Cards */
.result-card {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    background: #fff;
    transition: box-shadow 0.15s;
}
.result-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.5rem; gap: 0.5rem; }
.card-title { font-weight: 600; font-size: 0.95rem; flex: 1; }
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}
.badge-buy { background: #dcfce7; color: #16a34a; }
.badge-maybe { background: #fef9c3; color: #ca8a04; }
.badge-pass { background: #fee2e2; color: #dc2626; }
.card-prices {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
}
.price-item { background: #f9fafb; padding: 0.4rem 0.6rem; border-radius: 4px; }
.price-label { color: #888; font-size: 0.75rem; display: block; }
.price-value { font-weight: 600; color: #333; }
.card-reasoning { font-size: 0.85rem; color: #555; margin-bottom: 0.5rem; line-height: 1.5; }
.risk-flags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.5rem; }
.risk-pill {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    background: #fff7ed;
    color: #ea580c;
    border: 1px solid #fed7aa;
    border-radius: 12px;
    font-size: 0.75rem;
}
.category-notice {
    font-size: 0.8rem;
    color: #7c3aed;
    margin-bottom: 0.5rem;
    font-style: italic;
}
.confidence-badge {
    font-size: 0.75rem;
    color: #666;
    margin-bottom: 0.5rem;
}
.card-footer { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.4rem; }
.card-links { display: flex; gap: 0.75rem; font-size: 0.8rem; align-items: center; }
.contact-seller-btn {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    background: #16a34a;
    color: #fff;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    text-decoration: none;
}
.contact-seller-btn:hover { background: #15803d; text-decoration: none; }
.card-cost { font-size: 0.7rem; color: #0369a1; }
.card-distance { font-size: 0.75rem; color: #666; background: #f0f0f0; padding: 0.1rem 0.4rem; border-radius: 3px; }
.card-meta { font-size: 0.75rem; color: #999; }
.delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    color: #999;
    padding: 0.2rem;
}
.delete-btn:hover { color: #dc2626; }
.estimate-label {
    font-size: 0.7rem;
    color: #f59e0b;
    font-weight: 500;
}
.ebay-unavailable-label {
    font-size: 0.7rem;
    color: #dc2626;
    font-weight: 500;
}

/* Load More */
.load-more {
    display: block;
    margin: 1rem auto 0;
    width: auto;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 2rem;
    color: #999;
    font-size: 0.9rem;
}

/* Part-Out Results */
.partout-summary {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
    padding: 1rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 1rem;
}
.partout-score {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    padding: 0.5rem 0.75rem;
    border-radius: 10px;
    text-align: center;
    min-width: 80px;
}
.partout-stats {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    min-width: 200px;
}
.partout-stat {
    background: #fff;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}
.partout-stat-label { font-size: 0.7rem; color: #888; display: block; text-transform: uppercase; letter-spacing: 0.5px; }
.partout-stat-value { font-size: 1.1rem; font-weight: 700; color: #333; }
.partout-rec {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.partout-rec-part_out { background: #dcfce7; color: #16a34a; }
.partout-rec-sell_whole { background: #fef9c3; color: #ca8a04; }
.partout-rec-pass { background: #fee2e2; color: #dc2626; }

.partout-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}
.partout-table th {
    background: #f3f4f6;
    padding: 0.5rem 0.6rem;
    text-align: left;
    font-size: 0.75rem;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 2px solid #e5e7eb;
}
.partout-table td {
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid #f3f4f6;
}
.partout-table tr.row-green { background: #f0fdf4; }
.partout-table tr.row-yellow { background: #fefce8; }
.partout-table tr.row-red { background: #fef2f2; }
.partout-table tr.totals-row {
    font-weight: 700;
    background: #f3f4f6;
    border-top: 2px solid #e5e7eb;
}

.partout-comparison {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    color: #1e40af;
    margin-bottom: 1rem;
}
.partout-reasoning {
    font-size: 0.85rem;
    color: #555;
    margin-bottom: 0.75rem;
    line-height: 1.5;
}
.partout-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Responsive */
@media (max-width: 640px) {
    .container { padding: 0.75rem; }
    .card-prices { grid-template-columns: 1fr 1fr; }
    .filter-bar { gap: 0.25rem; }
    .results-header { flex-direction: column; align-items: flex-start; }
}
