:root {
  --jade: #1E4D3E;
  --jade-deep: #143529;
  --jade-tint: #E2ECE7;
  --ink: #18201D;
  --ink-2: #4B5752;
  --ink-3: #7A8580;
  --mist: #F2F4F1;
  --card: #FFFFFF;
  --line: #D9DED9;
  --sand: #EADFC4;
  --sand-ink: #6B5520;
  --rose: #F3DCDC;
  --rose-ink: #8A2E2E;
  --radius-photo: 12px;
  --r: 12px;
  --font: 'Schibsted Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--mist); color: var(--ink);
  font: 400 16px/1.5 var(--font); font-feature-settings: 'tnum' 0;
}
img { display: block; max-width: 100%; }
a { color: var(--jade); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--jade); outline-offset: 2px; }

/* ---------- header ---------- */
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  max-width: 1200px; margin: 0 auto; padding: 16px 20px;
}
.brand { display: inline-flex; align-items: center; gap: 14px; color: var(--ink); text-decoration: none; }
.brand .logo-mark { width: auto; height: 38px; }
.brand .logo-word { width: auto; height: 13px; }
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: -40px 0 56px; }
.hero-top .bar-contact { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.3); color: #fff; }
.hero-top .bar-contact:hover { background: rgba(255,255,255,.24); border-color: rgba(255,255,255,.5); }
.brand-admin { font-weight: 600; font-size: 15px; color: var(--ink-2); padding-left: 14px; border-left: 1px solid var(--line); }
.bar-contact { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; text-decoration: none; padding: 5px 14px 5px 5px; border-radius: 999px; background: var(--jade-tint); border: 1px solid transparent; color: var(--jade-deep); }
.bar-contact { white-space: nowrap; }
.bar-contact img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.bar-contact:hover { background: #d3e4dc; }

/* ---------- search hero ---------- */
main { max-width: 1200px; margin: 0 auto; padding: 0 20px 48px; }
.search {
  position: relative; isolation: isolate; overflow: hidden;
  background: var(--jade-deep); color: #fff; border-radius: 22px;
  padding: 72px 32px 28px; margin: 20px 0 28px;
}
.search-bg { position: absolute; inset: 0; z-index: -1; background: center 45% / cover no-repeat; }
.search-bg::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(100deg, rgba(16, 42, 33, .94) 0%, rgba(16, 42, 33, .8) 40%, rgba(16, 42, 33, .25) 100%);
}
.search .searchbox { max-width: 760px; }
.search h1 { margin-top: 0; }
.search h1 {
  margin: 0 0 22px; font-size: clamp(34px, 6vw, 60px); line-height: 1.02; font-weight: 800; letter-spacing: -0.035em; max-width: 14ch;
}
.offer-toggle { display: inline-flex; background: rgba(255,255,255,.12); padding: 4px; border-radius: 999px; margin-bottom: 14px; }
.offer-toggle button {
  border: 0; background: transparent; color: #fff; padding: 8px 16px; border-radius: 999px; font-weight: 600; font-size: 15px; cursor: pointer;
}
.offer-toggle button[aria-pressed="true"] { background: #fff; color: var(--jade-deep); }
.searchbox {
  display: flex; align-items: center; gap: 12px; background: #fff; color: var(--ink);
  border-radius: 14px; padding: 0 18px; height: 60px;
}
.searchbox svg { width: 22px; height: 22px; flex: none; fill: none; stroke: var(--ink-3); stroke-width: 2; stroke-linecap: round; }
.searchbox input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 18px; height: 100%; }
.searchbox:focus-within { outline: 3px solid #9ED3BE; outline-offset: 2px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.filters select {
  appearance: none; -webkit-appearance: none;
  background: rgba(255,255,255,.1) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='white' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 12px center / 10px;
  color: #fff; border: 1px solid rgba(255,255,255,.28); border-radius: 10px; padding: 9px 32px 9px 12px; font-size: 15px; cursor: pointer;
}
.filters select option { color: var(--ink); }
.filters select:hover { background-color: rgba(255,255,255,.18); }

/* ---------- results ---------- */
.results-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 2px 14px; }
.rh-right { display: flex; align-items: center; gap: 14px; }
#sort { appearance: none; -webkit-appearance: none; border: 1px solid var(--line); border-radius: var(--r); padding: 7px 30px 7px 12px; font-size: 15px; cursor: pointer;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%2318201D' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 11px center / 10px; }
#count { margin: 0; color: var(--ink-2); font-weight: 500; }
.link { background: none; border: 0; padding: 0; color: var(--jade); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 28px 22px; }
.card-hit { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 0; cursor: pointer; border-radius: var(--radius-photo); }
.ph { position: relative; aspect-ratio: 4 / 3; border-radius: var(--radius-photo); overflow: hidden; background: #E2E6E2; }
.ph img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.card-hit:hover .ph img { transform: scale(1.03); }
.noimg { width: 100%; height: 100%; display: grid; place-items: center; background: linear-gradient(160deg, #E4EAE6, #D4DDD8); }
.noimg svg { width: 56px; height: 56px; fill: none; stroke: #9AA8A1; stroke-width: 2; stroke-linejoin: round; }
.noimg.big svg { width: 80px; height: 80px; }
.badges { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; }
.badge { display: inline-block; font-size: 13px; font-weight: 600; padding: 3px 9px; border-radius: 6px; background: #fff; color: var(--ink); vertical-align: middle; }
.badge.s-reserved { background: var(--sand); color: var(--sand-ink); }
.badge.s-sold, .badge.s-rented { background: var(--rose); color: var(--rose-ink); }
.badge.sample { background: var(--ink); color: #fff; }
.pcount { position: absolute; right: 10px; bottom: 10px; font-size: 13px; font-weight: 600; color: #fff; background: rgba(0,0,0,.55); padding: 3px 9px; border-radius: 6px; }
.cb { padding: 12px 2px 0; }
.price { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.cb h3 { margin: 2px 0 0; font-size: 16px; font-weight: 600; line-height: 1.35; }
.cb .loc { margin: 2px 0 0; color: var(--ink-2); font-size: 15px; }
.cb .spec { margin: 6px 0 0; color: var(--ink-3); font-size: 14px; white-space: pre-wrap; }
.card.done .ph img { filter: grayscale(.7); opacity: .8; }
.card.done .price { color: var(--ink-3); }

.empty { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 28px; max-width: 560px; }
.empty p { margin: 0 0 8px; color: var(--ink-2); }
.empty p strong { color: var(--ink); font-size: 18px; }
.empty .btn { margin-top: 10px; }

.foot {
  max-width: 1200px; margin: 0 auto; padding: 28px 20px 44px; border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 18px 32px;
}
.agent { display: flex; align-items: center; gap: 14px; }
.agent img { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; }
.agent p { margin: 0; }
.agent-name { font-weight: 700; }
.agent-tag { color: var(--ink-2); font-size: 15px; }
.foot-links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 22px; font-size: 15px; }
.foot-links a { color: var(--ink-2); text-decoration: none; font-weight: 500; }
.foot-links a:hover { color: var(--jade); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; padding: 0 20px; border-radius: var(--r); border: 0;
  background: var(--jade); color: #fff; font-weight: 600; font-size: 16px; text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--jade-deep); }
.btn.ghost { background: var(--jade-tint); color: var(--jade-deep); }
.btn.ghost:hover { background: #d3e4dc; }
.btn.danger { background: var(--rose); color: var(--rose-ink); }
.btn.small { height: 36px; padding: 0 14px; font-size: 14px; border-radius: var(--r); }

/* ---------- detail sheet ---------- */
dialog#detail {
  padding: 0; border: 0; background: transparent; max-width: none; max-height: none;
  width: 100%; height: 100%; margin: 0;
}
dialog#detail::backdrop { background: rgba(14, 22, 19, .55); }
dialog#detail[open] .sheet { animation: rise .28s cubic-bezier(.2,.8,.2,1); }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet {
  position: relative; background: var(--card); width: min(860px, 100%); margin: 40px auto; border-radius: 20px;
  max-height: calc(100% - 80px); overflow: auto; overscroll-behavior: contain;
}
.close {
  position: sticky; top: 12px; float: right; margin: 12px 12px -56px 0; z-index: 2;
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255,255,255,.94); cursor: pointer;
  display: grid; place-items: center; box-shadow: 0 2px 10px rgba(0,0,0,.18);
}
.close svg { width: 20px; height: 20px; fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; }
.gallery { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; background: #E2E6E2; border-radius: 20px 20px 0 0; scrollbar-width: thin; }
.gallery img, .gallery .noimg { flex: 0 0 100%; aspect-ratio: 3 / 2; object-fit: cover; scroll-snap-align: start; }
.gallery.multi img { flex-basis: 88%; }
.gallery.multi img + img { border-left: 3px solid #fff; }
.d-body { padding: 24px 28px 8px; }
.d-meta { margin: 0 0 4px; color: var(--ink-2); font-weight: 500; }
.d-body h2 { margin: 0; font-size: clamp(24px, 3.4vw, 32px); line-height: 1.15; letter-spacing: -0.02em; font-weight: 700; }
.d-price { margin: 10px 0 0; font-size: clamp(28px, 4.2vw, 38px); font-weight: 800; letter-spacing: -0.03em; color: var(--jade); font-variant-numeric: tabular-nums; }
.d-loc { margin: 2px 0 0; color: var(--ink-2); font-size: 17px; }
.specs { display: flex; flex-wrap: wrap; gap: 8px; margin: 22px 0 0; }
.specs div { flex: 1 1 120px; background: var(--mist); border-radius: var(--r); padding: 10px 14px; }
.specs dt { color: var(--ink-3); font-size: 14px; }
.specs dd { margin: 2px 0 0; font-weight: 700; font-size: 18px; }
.d-terms { margin: 16px 0 0; padding: 12px 14px; background: var(--jade-tint); border-radius: var(--r); color: var(--jade-deep); font-weight: 500; }
.d-desc { margin: 18px 0 0; color: var(--ink-2); max-width: 68ch; }
.d-desc p { margin: 0 0 12px; }
.d-actions {
  position: sticky; bottom: 0; display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 28px 18px;
  background: #fff; border-top: 1px solid var(--line);
}
.d-actions .btn { flex: 1 1 auto; }
.d-agent { flex: 1 0 100%; display: flex; align-items: center; gap: 10px; margin: 0 0 4px; color: var(--ink-2); font-size: 15px; font-weight: 500; }
.d-agent img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.d-actions .btn:first-child { flex: 2 1 auto; }

@media (max-width: 640px) {
  .bar { padding: 14px 16px; }
  main { padding: 0 16px 40px; }
  .search { padding: 44px 18px 18px; border-radius: 18px; }
  .search-bg { background-position: center 30%; }
  .search-bg::after { background: linear-gradient(180deg, rgba(16, 42, 33, .55) 0%, rgba(16, 42, 33, .85) 42%, rgba(16, 42, 33, .96) 100%); }
  .hero-top { margin: -28px 0 72px; }
  .brand { gap: 10px; }
  .brand .logo-mark { height: 28px; }
  .brand .logo-word { height: 9px; }
  .hero-top .bar-contact { font-size: 14px; padding-right: 12px; }
  .searchbox { height: 54px; }
  .filters select { flex: 1 1 calc(50% - 4px); min-width: 0; }
  .searchbox input { font-size: 17px; }
  .grid { grid-template-columns: 1fr; }
  .sheet { margin: 0; width: 100%; max-height: 100%; height: 100%; border-radius: 0; }
  .gallery { border-radius: 0; }
  .d-body { padding: 20px 18px 8px; }
  .d-actions { padding: 12px 18px calc(14px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- admin ---------- */
.admin main { max-width: 980px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 24px; margin-bottom: 20px; }
.panel h1, .panel h2 { margin: 0 0 16px; letter-spacing: -0.02em; }
.panel h1 { font-size: 28px; }
.panel h2 { font-size: 20px; }
.notice { padding: 12px 16px; border-radius: var(--r); margin: 0 0 18px; font-weight: 500; }
.notice.ok { background: var(--jade-tint); color: var(--jade-deep); }
.notice.err { background: var(--rose); color: var(--rose-ink); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.field .hint { font-weight: 400; color: var(--ink-3); }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; background: #fff; font-size: 16px;
}
.field textarea { min-height: 160px; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--jade); outline-offset: 0; border-color: var(--jade); }
.row4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--jade); }
.photos-edit { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin-bottom: 10px; }
.photos-edit figure { margin: 0; position: relative; border-radius: var(--r); overflow: hidden; border: 1px solid var(--line); background: #fff; }
.photos-edit img { aspect-ratio: 4/3; object-fit: cover; width: 100%; }
.photos-edit figcaption { display: flex; justify-content: space-between; gap: 4px; padding: 6px 8px; font-size: 13px; }
.photos-edit .cover { position: absolute; top: 6px; left: 6px; }
.photos-edit button { background: none; border: 0; color: var(--jade); font-weight: 600; cursor: pointer; padding: 2px; font-size: 13px; }
.photos-edit button.rm { color: var(--rose-ink); }
.actions-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; align-items: center; }
.admin-list { width: 100%; border-collapse: collapse; }
.admin-list td { padding: 10px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
.admin-list tr:first-child td { border-top: 0; }
.admin-list .thumb { width: 72px; height: 54px; border-radius: var(--r); object-fit: cover; background: #E2E6E2; }
.admin-list .t { font-weight: 600; }
.admin-list .sub { color: var(--ink-3); font-size: 14px; }
.admin-list .act { text-align: right; white-space: nowrap; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.login { max-width: 400px; margin: 60px auto; }
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .row4 { grid-template-columns: repeat(2, 1fr); }
  .admin-list .thumb { width: 56px; height: 42px; }
  .admin-list .hide-sm { display: none; }
}
