:root {
  --deep: #051226;
  --navy: #0b2550;
  --ink: #e9f2ff;
  --muted: #9fb6d9;
  --sky: #5cb8ff;
  --sky-strong: #2f95f0;
  --gold: #ffc857;
  --danger: #ff7a7a;
  --glass: rgba(120, 170, 255, 0.08);
  --glass-strong: rgba(120, 170, 255, 0.14);
  --edge: rgba(160, 200, 255, 0.2);
  --radius-lg: 18px;
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; background: var(--deep); }
body {
  margin: 0;
  font: 16px/1.5 var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 10% -10%, #123a78 0%, transparent 60%),
    radial-gradient(900px 600px at 110% 10%, #0d3a6e 0%, transparent 55%),
    linear-gradient(180deg, var(--navy) 0%, var(--deep) 900px);
  background-repeat: no-repeat;
  background-color: var(--deep);
  min-height: 100vh;
}
a { color: var(--sky); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
img { max-width: 100%; display: block; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0 0 .5rem; }
h2 { font-size: 1.35rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 650; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

/* header */
.top {
  position: sticky; top: 0; z-index: 1000;
  background: rgba(5, 18, 38, 0.72);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--edge);
}
.top .wrap { display: flex; align-items: center; gap: 12px; height: 60px; }
.brand { color: var(--ink); font-family: var(--font-display); font-weight: 800; font-size: 1.2rem; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--sky) 0%, #1f5fc4 100%); display: grid; place-items: center; color: #041022; font-weight: 900; font-size: .95rem; box-shadow: inset 0 1px 0 rgba(255,255,255,.4); }
.top nav { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.top nav a:not(.btn) { color: var(--ink); }

/* buttons & forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: linear-gradient(180deg, var(--sky) 0%, var(--sky-strong) 100%);
  color: #04142c; font-weight: 700; font-size: .95rem;
  border: 0; border-radius: 999px; padding: 10px 18px; cursor: pointer;
  box-shadow: 0 6px 18px rgba(47, 149, 240, .35), inset 0 1px 0 rgba(255,255,255,.45);
  text-decoration: none; font-family: inherit;
}
.btn:hover { text-decoration: none; filter: brightness(1.07); }
.btn:disabled { opacity: .55; cursor: wait; }
.btn.ghost { background: var(--glass-strong); color: var(--ink); box-shadow: none; border: 1px solid var(--edge); }
.btn.danger { background: rgba(255, 122, 122, .15); color: var(--danger); box-shadow: none; border: 1px solid rgba(255,122,122,.4); }
.btn.small { padding: 6px 12px; font-size: .85rem; }
.btn.wide { width: 100%; padding: 14px; font-size: 1.05rem; }
.link { background: none; border: 0; color: var(--sky); cursor: pointer; font: inherit; padding: 0; }
.link.small { font-size: .85rem; color: var(--muted); }

label { display: block; font-size: .9rem; color: var(--muted); }
label > span { display: block; margin-bottom: 4px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink);
  background: rgba(3, 12, 28, .55);
  border: 1px solid var(--edge); border-radius: var(--radius-sm);
  padding: 10px 12px; margin-top: 4px;
}
label > span + input, label > span + select { margin-top: 0; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
select:disabled, input:disabled { opacity: .5; }
option { background: #0b2550; color: var(--ink); }
textarea { resize: vertical; min-height: 140px; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: #6e86ad; }
fieldset { border: 1px solid var(--edge); border-radius: var(--radius); padding: 14px; margin: 18px 0 0; }
legend { padding: 0 6px; color: var(--ink); font-weight: 650; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--ink); }
.check input { width: auto; margin: 0; }
.hint { color: var(--muted); font-size: .85rem; margin: 8px 0 0; }
.error { color: var(--danger); font-weight: 600; min-height: 1.2em; margin: 12px 0; }
.ok { color: #7ee2a8; }

.panel {
  background: var(--glass);
  border: 1px solid var(--edge);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}

/* hero map */
.hero { position: relative; margin: 16px 0 0; }
.hero-map { height: min(48vh, 440px); border-radius: var(--radius-lg); border: 1px solid var(--edge); overflow: hidden; background: #0a1c3a; }
.hero-copy {
  position: absolute; left: 16px; bottom: 16px; z-index: 500; max-width: 440px;
  padding: 16px 18px; border-radius: var(--radius);
  background: rgba(5, 18, 38, .78); border: 1px solid var(--edge);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  pointer-events: none;
}
.hero-copy h1 { font-size: clamp(1.9rem, 5vw, 3rem); font-weight: 800; letter-spacing: -0.025em; margin: 0 0 6px; }
.hero-copy p { margin: 0; color: var(--muted); }
.leaflet-tile-pane { filter: invert(1) hue-rotate(190deg) brightness(.85) saturate(.55) contrast(.95); }
.leaflet-container { font: inherit; background: #0a1c3a; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: #0b2550; color: var(--ink); border: 1px solid var(--edge); }
.leaflet-popup-content { margin: 10px 14px; line-height: 1.45; }
.pop-place { color: var(--muted); font-size: .85rem; margin-bottom: 4px; }
.pop b { color: var(--gold); font-weight: 700; }
.leaflet-control-attribution { background: rgba(5,18,38,.7) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--sky) !important; }
.leaflet-bar a { background: #0b2550; color: var(--ink); border-color: var(--edge); }

/* filters */
.filters { margin: 14px 0 0; padding: 14px; display: grid; gap: 10px; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; }
.filters .f-q { grid-column: 1 / -1; }
.filters .f-actions { display: flex; align-items: center; gap: 14px; }
@media (max-width: 860px) { .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); } .filters .f-actions { grid-column: 1 / -1; } }

/* category directory */
.directory { margin: 22px 0 6px; columns: 3 260px; column-gap: 28px; }
.dir-col { break-inside: avoid; margin: 0 0 18px; }
.dir-col h3 a { color: var(--ink); }
.dir-col h3 { border-bottom: 1px solid var(--edge); padding-bottom: 6px; margin-bottom: 6px; }
.dir-col ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.dir-col li a { font-size: .92rem; }

/* results */
.results-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 22px 0 10px; }
.results-head span { color: var(--muted); font-size: .9rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.card { display: flex; flex-direction: column; color: var(--ink); background: var(--glass); border: 1px solid var(--edge); border-radius: var(--radius); overflow: hidden; }
.card:hover { text-decoration: none; border-color: rgba(92,184,255,.6); }
.thumb { aspect-ratio: 4 / 3; background: rgba(3,12,28,.6); display: grid; place-items: center; color: #56709a; font-size: .85rem; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: 10px 12px 12px; }
.card-body h3 { font-size: 1rem; font-weight: 600; margin: 2px 0 4px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.price { color: var(--gold); font-weight: 800; font-size: 1.05rem; }
.loc { color: var(--muted); font-size: .85rem; }
.empty { padding: 28px; text-align: center; color: var(--muted); grid-column: 1 / -1; }
.more-wrap { text-align: center; margin: 18px 0 8px; }

/* listing page */
.back { display: inline-block; margin: 16px 0 10px; }
.listing-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 860px) { .listing-grid { grid-template-columns: 1fr; } }
.gallery .main-photo { width: 100%; max-height: 70vh; object-fit: contain; background: rgba(3,12,28,.7); border-radius: var(--radius-lg); border: 1px solid var(--edge); }
.nophoto { aspect-ratio: 4/3; display: grid; place-items: center; border-radius: var(--radius-lg); border: 1px dashed var(--edge); color: var(--muted); }
.thumbs { display: flex; gap: 8px; margin-top: 8px; overflow-x: auto; }
.thumbs button { padding: 0; border: 2px solid transparent; border-radius: var(--radius-sm); background: none; cursor: pointer; flex: 0 0 auto; }
.thumbs button[aria-current="true"] { border-color: var(--sky); }
.thumbs img { width: 72px; height: 56px; object-fit: cover; border-radius: 6px; }
.info { padding: 18px; }
.info .price { font-size: 1.8rem; }
.info h1 { font-size: 1.5rem; font-weight: 750; margin: 4px 0 8px; }
.meta { color: var(--muted); font-size: .92rem; margin-bottom: 12px; }
.contact-box { margin-top: 12px; padding: 12px; border-radius: var(--radius); background: rgba(3,12,28,.5); border: 1px solid var(--edge); }
.contact-box div + div { margin-top: 6px; }
.owner-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--edge); }
.notice { padding: 10px 12px; border-radius: var(--radius-sm); background: rgba(255,200,87,.12); border: 1px solid rgba(255,200,87,.4); color: var(--gold); margin-bottom: 12px; font-size: .92rem; }
.minimap { height: 200px; border-radius: var(--radius); margin-top: 14px; border: 1px solid var(--edge); overflow: hidden; }
.desc { margin-top: 18px; padding: 18px; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 80ch; }
.safety { color: var(--muted); font-size: .88rem; margin: 14px 0 0; max-width: 80ch; }

/* forms page */
.form-wrap { max-width: 760px; margin: 18px auto; padding: 20px; }
.form-wrap h1 { font-size: 1.7rem; font-weight: 800; }
.form-wrap > form > label, .form-wrap fieldset label { margin-top: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 12px; }
.row2 > label, .row3 > label { margin-top: 12px; }
@media (max-width: 600px) { .row2, .row3 { grid-template-columns: 1fr; } }
.previews { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.previews img { width: 92px; height: 70px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--edge); }
.narrow { max-width: 440px; }

/* account */
.mine { display: grid; gap: 10px; margin-top: 12px; }
.mine-row { display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px; border-radius: var(--radius); background: var(--glass); border: 1px solid var(--edge); }
.mine-row .thumb { width: 84px; border-radius: var(--radius-sm); overflow: hidden; }
.mine-row .acts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.tag { display: inline-block; font-size: .78rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--edge); color: var(--muted); }
.tag.live { color: #7ee2a8; border-color: rgba(126,226,168,.4); }
.tag.off { color: var(--gold); border-color: rgba(255,200,87,.4); }
@media (max-width: 600px) { .mine-row { grid-template-columns: 64px minmax(0, 1fr); } .mine-row .thumb { width: 64px; } .mine-row .acts { grid-column: 1 / -1; justify-content: flex-start; } }

/* footer, toast, loading */
.foot { margin: 40px 0 0; padding: 22px 0 36px; border-top: 1px solid var(--edge); color: var(--muted); font-size: .88rem; }
.foot p { margin: 0 0 6px; max-width: 80ch; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 2000; background: #0b2550; border: 1px solid var(--edge); color: var(--ink); padding: 12px 18px; border-radius: 999px; box-shadow: 0 10px 30px rgba(0,0,0,.4); max-width: calc(100% - 32px); }
.toast[hidden] { display: none; }
.loading { color: var(--muted); padding: 30px 0; text-align: center; }
.page-error { max-width: 640px; margin: 30px auto; padding: 20px; }

/* admin */
.admin-table { width: 100%; border-collapse: collapse; font-size: .9rem; margin-top: 12px; }
.admin-table th, .admin-table td { text-align: left; padding: 8px; border-bottom: 1px solid var(--edge); vertical-align: top; }
.admin-table th { color: var(--muted); font-weight: 600; }
.admin-table td .btn { margin: 2px; }
.table-scroll { overflow-x: auto; }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }
