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

:root {
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --sale: #3b82f6;
    --rent: #22c55e;
    --danger: #ef4444;
    --border: #334155;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

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

/* Header */
header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
    position: sticky;
    top: 0;
    z-index: 1000;
}
.header-inner {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.header-inner h1 { font-size: 1.25rem; white-space: nowrap; }
.header-inner nav { display: flex; gap: 0.5rem; align-items: center; }
.header-inner nav a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
}
.header-inner nav a:hover, .header-inner nav a.active {
    background: var(--bg-hover);
    color: var(--text);
}

/* Dashboard */
.dashboard-layout {
    display: grid;
    grid-template-columns: 1fr 420px;
    height: calc(100vh - 57px);
    max-width: 1600px;
    margin: 0 auto;
}

.map-container { position: relative; }
#map {
    width: 100%;
    height: 100%;
    min-height: 400px;
    z-index: 1;
}

.sidebar {
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border);
    background: var(--bg);
}

/* Filters */
.filter-bar {
    display: flex;
    gap: 0.4rem;
    padding: 0.6rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.filter-bar select, .filter-bar input {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
    flex: 1;
    min-width: 80px;
}
.filter-bar input { flex: 2; }

/* Stats */
.stats-bar {
    display: flex;
    gap: 1rem;
    padding: 0.5rem 0.6rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

/* Listings scroll area */
.listings-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 0.6rem;
}

.listing-grid {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.listing-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    transition: border-color 0.15s;
}
.listing-card:hover { border-color: var(--accent); }

.card-image {
    width: 100%;
    height: 140px;
    overflow: hidden;
    background: var(--bg-hover);
    position: relative;
}
.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.card-image-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 2.5rem;
}
.fav-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(0,0,0,0.6);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.card-body { padding: 0.6rem; }

.card-price {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--accent);
}
.card-title {
    font-size: 0.9rem;
    margin: 0.15rem 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.card-details {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.card-address {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0.15rem 0;
}
.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0.3rem 0;
}
.type-badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
}
.type-badge.for_sale { background: rgba(59,130,246,0.2); color: var(--sale); }
.type-badge.for_rent { background: rgba(34,197,94,0.2); color: var(--rent); }

.card-actions {
    display: flex;
    gap: 0.3rem;
    margin-top: 0.3rem;
}

/* Buttons */
.btn-sm {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}
.btn-sm:hover { background: var(--bg-hover); }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); }
.btn-primary {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.35rem 0.7rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.8rem;
}
.btn-outline:hover { background: var(--bg-hover); }
.btn-lg { padding: 0.6rem 1.5rem; font-size: 1rem; }

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
    color: var(--text-muted);
}
.empty-icon { font-size: 3rem; margin-bottom: 0.5rem; }
.empty-state h3 { margin-bottom: 0.3rem; color: var(--text); }
.empty-state p { margin-bottom: 1rem; }

/* Loading */
.loading { padding: 1rem; text-align: center; color: var(--text-muted); }

/* Popup */
.popup-content { font-size: 0.85rem; line-height: 1.5; }
.popup-price { font-weight: 700; color: var(--accent); }
.popup-content a { color: var(--accent); }

/* Add page */
.add-page {
    max-width: 700px;
    margin: 2rem auto;
    padding: 0 1rem;
}
.add-form-container {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 1.5rem;
}
.add-form-container h2 { margin-bottom: 1rem; }
.add-section { margin-bottom: 1.5rem; }
.add-section h3 { font-size: 1rem; margin-bottom: 0.5rem; }
.help-text { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.5rem; }

.url-input-row {
    display: flex;
    gap: 0.5rem;
}
.input-url {
    flex: 1;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem 0.7rem;
    font-size: 0.9rem;
}
.url-status { margin-top: 0.5rem; font-size: 0.85rem; }
.url-status .success { color: var(--rent); }
.url-status .error { color: var(--danger); }
.url-status .warning { color: #f59e0b; }
.url-status .loading { color: var(--accent); padding: 0; text-align: left; }

/* Form */
.form-row {
    display: flex;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
}
.form-row .form-group { flex: 1; }
.form-group { margin-bottom: 0.6rem; }
.form-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}
.form-group input, .form-group select {
    width: 100%;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.45rem 0.6rem;
    font-size: 0.9rem;
}
.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--accent);
}

/* Custom marker */
.custom-marker {
    background: none !important;
    border: none !important;
    font-size: 1.3rem;
    display: flex !important;
    align-items: center;
    justify-content: center;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Mobile */
@media (max-width: 768px) {
    .dashboard-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
    #map { height: 50vh; }
    .sidebar { max-height: 50vh; }
}