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

:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface2: #242836;
    --border: #2e3344;
    --text: #e1e4ed;
    --text-dim: #8b91a5;
    --primary: #6c8cff;
    --success: #4ade80;
    --warning: #fbbf24;
    --danger: #f87171;
    --info: #38bdf8;
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }

.navbar { display: flex; align-items: center; gap: 2rem; padding: 0.75rem 2rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.nav-brand { color: var(--primary); font-weight: 700; font-size: 1.1rem; text-decoration: none; }
.nav-links { display: flex; gap: 1rem; flex: 1; }
.nav-version { font-size: 0.7rem; color: var(--text-dim); }
.nav-link { color: var(--text-dim); text-decoration: none; padding: 0.25rem 0.5rem; border-radius: 4px; }
.nav-link:hover { color: var(--text); background: var(--surface2); }

.container { max-width: 1400px; margin: 0 auto; padding: 1.5rem; }

.page-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.5rem; }
.count { color: var(--text-dim); font-weight: 400; }

.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.5rem; padding: 1rem; background: var(--surface); border-radius: 8px; border: 1px solid var(--border); }

.input { background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 0.5rem 0.75rem; border-radius: 6px; font-size: 0.875rem; }
.input:focus { outline: none; border-color: var(--primary); }
.input-sm { width: 100px; }
.textarea { width: 100%; resize: vertical; }

.btn { display: inline-block; padding: 0.5rem 1rem; background: var(--primary); color: #fff; border: none; border-radius: 6px; cursor: pointer; text-decoration: none; font-size: 0.875rem; }
.btn:hover { opacity: 0.9; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); }

.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 500; background: var(--surface2); color: var(--text-dim); }
.badge-success, .status-active { background: rgba(74,222,128,0.15); color: var(--success); }
.badge-warning, .status-expired { background: rgba(251,191,36,0.15); color: var(--warning); }
.badge-info, .status-sold { background: rgba(56,189,248,0.15); color: var(--info); }
.badge-primary, .status-bookmarked { background: rgba(108,140,255,0.15); color: var(--primary); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; transition: border-color 0.2s; }
.card:hover { border-color: var(--primary); }
.card-img { width: 100%; height: 200px; object-fit: cover; display: block; }
.card-img-placeholder { height: 200px; display: flex; align-items: center; justify-content: center; background: var(--surface2); color: var(--text-dim); }
.card-body { padding: 0.75rem; }
.card-price { font-size: 1.25rem; font-weight: 700; color: var(--success); }
.card-title { display: block; color: var(--text); text-decoration: none; font-weight: 500; margin: 0.25rem 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-title:hover { color: var(--primary); }
.card-location { font-size: 0.8rem; color: var(--text-dim); }
.card-meta { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.5rem; }
.score { font-size: 0.8rem; color: var(--primary); font-weight: 600; }

.card { position: relative; }
.card-select { position: absolute; top: 0.5rem; left: 0.5rem; z-index: 2; background: rgba(0,0,0,0.5); border-radius: 4px; padding: 0.2rem 0.3rem; cursor: pointer; }
.card-select input { cursor: pointer; width: 16px; height: 16px; }

.view-toggle { display: flex; gap: 0.25rem; margin-left: auto; }
.view-btn { background: var(--surface2); color: var(--text-dim); border: 1px solid var(--border); font-size: 1rem; line-height: 1; padding: 0.35rem 0.5rem; }
.view-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.bulk-actions { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; padding: 0.75rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }

/* List view */
.list-view .grid { display: flex; flex-direction: column; gap: 0.5rem; }
.list-view .card { display: flex; flex-direction: row; border-radius: 6px; }
.list-view .card-select { position: static; background: none; display: flex; align-items: center; padding: 0 0.5rem 0 0.75rem; }
.list-view .card-img { width: 120px; height: 80px; min-width: 120px; border-radius: 0; }
.list-view .card-img-placeholder { width: 120px; height: 80px; min-width: 120px; font-size: 0.7rem; }
.list-view .card-body { display: flex; align-items: center; gap: 1rem; flex: 1; padding: 0.5rem 0.75rem; overflow: hidden; }
.list-view .card-price { font-size: 1rem; min-width: 70px; }
.list-view .card-title { margin: 0; }
.list-view .card-location { display: none; }
.list-view .card-meta { margin-top: 0; margin-left: auto; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1.5rem; }
.page-info { color: var(--text-dim); font-size: 0.875rem; }

.detail-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
@media (max-width: 768px) { .detail-layout { grid-template-columns: 1fr; } }

.gallery { display: flex; flex-direction: column; gap: 0.5rem; }
.gallery-img { width: 100%; border-radius: 8px; }
.card-img-placeholder.large { height: 300px; border-radius: 8px; }

.detail-price { font-size: 2rem; font-weight: 700; color: var(--success); margin-bottom: 1rem; }
.detail-info { display: flex; flex-direction: column; gap: 1rem; }
.detail-row label { display: block; font-size: 0.8rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.25rem; }
.description { white-space: pre-wrap; max-height: 300px; overflow-y: auto; }

.score-bar { position: relative; height: 24px; background: var(--surface2); border-radius: 12px; overflow: hidden; }
.score-fill { position: absolute; top: 0; left: 0; height: 100%; background: var(--primary); border-radius: 12px; }
.score-bar span { position: relative; z-index: 1; line-height: 24px; padding-left: 8px; font-size: 0.8rem; font-weight: 600; }
.score-bar-interactive { cursor: pointer; }
.score-bar-interactive:hover { box-shadow: 0 0 0 2px var(--border); }

.search-list { display: flex; flex-direction: column; gap: 1rem; }
.search-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; }
.search-card-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
.search-card-header h3 { font-size: 1.1rem; }
.search-card-body { font-size: 0.875rem; color: var(--text-dim); margin-bottom: 0.75rem; }
.search-card-body div { margin-bottom: 0.25rem; }
.search-card-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.search-card-order { display: flex; gap: 0.25rem; margin-left: auto; }
.btn-icon { min-width: 2rem; padding: 0.25rem 0.5rem; text-align: center; }

.form { max-width: 600px; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.875rem; margin-bottom: 0.25rem; color: var(--text-dim); }
.form-group .input { width: 100%; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; }
.form-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; }
.checkbox-label { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; padding-top: 1.5rem; }

.scrape-progress-card { background: var(--surface); border-radius: 8px; border: 1px solid var(--border); padding: 1.5rem; }
.progress-status { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.progress-stat { color: var(--text-dim); font-size: 0.9rem; }
.badge-running { background: var(--info); color: #000; }
.badge-success { background: var(--success); color: #000; }
.badge-error { background: var(--danger); color: #000; }
.badge-warning { background: var(--warning); color: #000; }
.progress-error { background: rgba(248, 113, 113, 0.1); border: 1px solid var(--danger); color: var(--danger); padding: 0.75rem; border-radius: 6px; margin-bottom: 1rem; }
.progress-log { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 1rem; max-height: 500px; overflow-y: auto; font-family: monospace; font-size: 0.8rem; }
.log-line { padding: 0.15rem 0; color: var(--text-dim); border-bottom: 1px solid var(--border); }
.log-line:last-child { border-bottom: none; }
.progress-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; }

.text-success { color: var(--success); }
.text-error { color: var(--danger); }
.empty { text-align: center; padding: 3rem; color: var(--text-dim); grid-column: 1 / -1; }

.change-history { display: flex; flex-direction: column; gap: 0.5rem; max-height: 300px; overflow-y: auto; }
.change-entry { display: flex; align-items: baseline; gap: 0.5rem; padding: 0.5rem 0.75rem; background: var(--surface2); border-radius: 6px; font-size: 0.85rem; flex-wrap: wrap; }
.change-date { color: var(--text-dim); font-size: 0.75rem; min-width: 130px; }
.change-field { text-transform: capitalize; font-size: 0.7rem; }
.change-old { color: var(--danger); word-break: break-word; }
.change-arrow { color: var(--text-dim); }
.change-new { color: var(--success); word-break: break-word; }

/* Map view — Leaflet dark theme overrides */
#map-container { z-index: 1; }
.leaflet-popup-content-wrapper { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; }
.leaflet-popup-tip { background: var(--surface); }
.leaflet-popup-content a { color: var(--primary); text-decoration: none; }
.leaflet-popup-content a:hover { text-decoration: underline; }
.leaflet-control-zoom a { background: var(--surface) !important; color: var(--text) !important; border-color: var(--border) !important; }
.leaflet-control-zoom a:hover { background: var(--surface2) !important; }
.leaflet-control-attribution { background: rgba(15,17,23,0.7) !important; color: var(--text-dim) !important; }
.leaflet-control-attribution a { color: var(--text-dim) !important; }
/* Cluster icons styled via iconCreateFunction in JS */
