:root {
    --bg: #f4f6fb;
    --panel: #ffffff;
    --text: #1d2433;
    --muted: #6b7489;
    --line: #e3e7ef;
    --brand: #2b59c3;
    --brand-dark: #1f438f;
    --success: #1f8a4c;
    --success-bg: #e3f5ea;
    --danger: #c0392b;
    --danger-bg: #fbe6e3;
    --info: #22668d;
    --info-bg: #e2f0f8;
    --warn: #9a6400;
    --warn-bg: #fff3d6;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 4px 16px rgba(20, 30, 60, .05);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .6rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }

.topbar {
    background: #172442;
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 1000;
}
.topbar-inner {
    max-width: 1320px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .6rem 1rem;
    flex-wrap: wrap;
}
.brand { color: #fff; font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.nav a {
    color: #cfd8ee;
    padding: .4rem .7rem;
    border-radius: 8px;
    font-size: .92rem;
}
.nav a:hover { background: rgba(255, 255, 255, .08); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(255, 255, 255, .16); color: #fff; }
.topbar form { margin: 0; }
.topbar .link-button { color: #cfd8ee; background: none; border: 0; cursor: pointer; font-size: .9rem; }

.container { max-width: 1320px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head p { margin: .2rem 0 0; color: var(--muted); }

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.1rem;
    margin-bottom: 1rem;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.layout-side { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1rem; align-items: start; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem; box-shadow: var(--shadow); }
.stat .value { font-size: 1.6rem; font-weight: 700; }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat a { color: inherit; }

.listing-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.listing-card .photo {
    position: relative;
    aspect-ratio: 4 / 3;
    background: #dfe4ee center / cover no-repeat;
    display: block;
}
.listing-card .photo .score {
    position: absolute; top: .5rem; right: .5rem;
    background: rgba(23, 36, 66, .85); color: #fff;
    border-radius: 999px; padding: .15rem .6rem; font-size: .8rem; font-weight: 700;
}
.listing-card .photo .source {
    position: absolute; bottom: .5rem; left: .5rem;
    background: rgba(255, 255, 255, .92); color: var(--text);
    border-radius: 6px; padding: .1rem .45rem; font-size: .75rem; font-weight: 600;
}
.listing-card .photo .noimg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .9rem; }
.listing-card .body { padding: .75rem .9rem .9rem; display: flex; flex-direction: column; gap: .3rem; flex: 1; }
.listing-card .price { font-size: 1.2rem; font-weight: 700; }
.listing-card .title { font-weight: 600; color: var(--text); }
.listing-card .meta { color: var(--muted); font-size: .88rem; }.listing-card .foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: .4rem; gap: .5rem; }

.badges { display: flex; flex-wrap: wrap; gap: .3rem; }
.badge { display: inline-block; font-size: .74rem; font-weight: 600; border-radius: 999px; padding: .12rem .55rem; background: #eef1f7; color: #3b4660; white-space: nowrap; }
.badge.success { background: var(--success-bg); color: var(--success); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.status-new { background: #eef1f7; }
.badge.status-interested, .badge.status-touring { background: var(--info-bg); color: var(--info); }
.badge.status-contacted, .badge.status-applied { background: var(--success-bg); color: var(--success); }
.badge.status-rejected, .badge.status-hidden { background: var(--danger-bg); color: var(--danger); }

.alert { border-radius: 10px; padding: .7rem .9rem; margin-bottom: 1rem; border: 1px solid transparent; }
.alert.success { background: var(--success-bg); color: var(--success); border-color: #bfe6cf; }
.alert.danger { background: var(--danger-bg); color: var(--danger); border-color: #f2c4bd; }
.alert.warn { background: var(--warn-bg); color: var(--warn); border-color: #f1dca7; }
.alert.info { background: var(--info-bg); color: var(--info); border-color: #bcdcee; }
.alert ul { margin: .3rem 0 0 1.1rem; padding: 0; }

.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; align-items: end; }
label { display: block; font-size: .82rem; font-weight: 600; color: #4a5470; margin-bottom: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
    width: 100%;
    padding: .5rem .6rem;
    border: 1px solid #cfd6e4;
    border-radius: 8px;
    background: #fff;
    font: inherit;
    color: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(43, 89, 195, .25); border-color: var(--brand); }
textarea { min-height: 110px; resize: vertical; }
.checkbox { display: flex; align-items: center; gap: .45rem; font-weight: 500; font-size: .92rem; color: var(--text); margin: .2rem 0; }
.checkbox input { width: 1rem; height: 1rem; }
.help { color: var(--muted); font-size: .82rem; margin-top: .2rem; }
.field { margin-bottom: .8rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 1rem; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
    border: 1px solid var(--brand); background: var(--brand); color: #fff;
    padding: .5rem .9rem; border-radius: 8px; font: inherit; font-weight: 600; font-size: .9rem;
    cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--brand); }
.btn.secondary:hover { background: #f0f4fc; }
.btn.small { padding: .3rem .6rem; font-size: .82rem; }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .3rem .8rem; margin-bottom: .6rem; }
.section-head h2 { margin: 0; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .5rem .55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .02em; }
tr:hover td { background: #fafbfe; }
.table-wrap { overflow-x: auto; }
.num { text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.small { font-size: .85rem; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .5rem; }
.gallery a { display: block; aspect-ratio: 4 / 3; background: #dfe4ee center / cover no-repeat; border-radius: 8px; }
.hero-photo { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; background: #dfe4ee; display: block; }

.dl { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.dl dt { color: var(--muted); font-size: .88rem; }
.dl dd { margin: 0; font-weight: 500; }

#map { height: calc(100vh - 230px); min-height: 460px; border-radius: var(--radius); border: 1px solid var(--line); }
.map-popup img { width: 220px; height: 130px; object-fit: cover; border-radius: 6px; display: block; margin-bottom: .35rem; }
.map-popup { font-size: .85rem; }

.pagination { display: flex; gap: .3rem; flex-wrap: wrap; margin: 1rem 0; }
.pagination a, .pagination span { padding: .35rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: .88rem; }
.pagination .current { background: var(--brand); color: #fff; border-color: var(--brand); }
.pagination .disabled { color: #b5bccb; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-card { width: 100%; max-width: 380px; }

.steps { margin: 0; padding-left: 1.2rem; }
.steps li { margin-bottom: .45rem; }

code { background: #eef1f7; border-radius: 5px; padding: .05rem .35rem; font-size: .88em; }

.tabs { display: flex; flex-wrap: wrap; gap: .3rem; border-bottom: 1px solid var(--line); margin: 0 0 1rem; }
.tabs a { padding: .55rem .9rem; border: 1px solid transparent; border-bottom: none; border-radius: 8px 8px 0 0; color: var(--muted); font-weight: 600; font-size: .92rem; margin-bottom: -1px; }
.tabs a:hover { color: var(--brand); text-decoration: none; }
.tabs a.active { background: var(--panel); color: var(--text); border-color: var(--line); }
.tabs .count { display: inline-block; margin-left: .3rem; font-size: .75rem; background: #eef1f7; border-radius: 999px; padding: 0 .45rem; }
.rent-list { margin: 0; padding: 0; list-style: none; font-size: .86rem; }
.rent-list li { white-space: nowrap; }
.elig-ok { color: var(--success); }
.elig-too_high, .elig-too_low { color: var(--danger); }
.elig-unknown { color: var(--muted); }

@media (max-width: 900px) {
    .layout-side, .grid-2, .grid-3 { grid-template-columns: 1fr; }
    #map { height: 70vh; }
}

@media (max-width: 560px) {
    .container { padding: 1rem .7rem 3rem; }
    .nav a { padding: .35rem .5rem; font-size: .85rem; }
    .grid-cards { grid-template-columns: 1fr; }
    h1 { font-size: 1.3rem; }
}
