:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --ink: #1f2a2e;
  --ink-2: #4a5559;
  --muted: #7a8487;
  --line: #e4ded4;
  --accent: #2f5d50;        /* deep pine */
  --accent-ink: #ffffff;
  --accent-soft: #e6efe9;
  --warn: #9a6a12;
  --warn-soft: #fbf1dc;
  --err: #a33a2c;
  --err-soft: #fbe9e5;
  --ok: #2f6b3f;
  --ok-soft: #e5f2e8;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31, 42, 46, .05), 0 6px 20px rgba(31, 42, 46, .05);
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 var(--sans); }
img { max-width: 100%; display: block; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--serif); font-weight: 650; line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.7rem, 3.6vw, 2.4rem); }
h2 { font-size: 1.3rem; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.center { text-align: center; }
[hidden] { display: none !important; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.main { padding-top: 28px; padding-bottom: 64px; min-height: 70vh; }

/* Top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; }
.brand { font-family: var(--serif); font-weight: 650; font-size: 1.25rem; color: var(--ink); text-decoration: none; }
.brand-tag { font: 600 .7rem var(--sans); text-transform: uppercase; letter-spacing: .08em; background: var(--accent-soft); color: var(--accent); padding: 3px 8px; border-radius: 99px; vertical-align: middle; margin-left: 6px; }
.nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nav a { color: var(--ink-2); text-decoration: none; padding: 8px 12px; border-radius: 8px; font-weight: 500; font-size: .95rem; }
.nav a:hover { background: var(--bg); }
.nav a.active { color: var(--accent); background: var(--accent-soft); }
.nav a.btn { color: var(--accent-ink); }
.nav a.btn:hover { background: #264c41; }

.footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
.footer-inner { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 24px 16px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px; padding: 11px 20px; font: 600 1rem var(--sans); text-decoration: none; cursor: pointer; transition: background .15s; }
.btn:hover { background: #264c41; }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-sm { padding: 7px 14px; font-size: .9rem; }
.btn-lg { padding: 14px 28px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-danger { background: var(--err); }
.btn-danger:hover { background: #8a2f23; }
.btn-link { background: none; border: 0; color: var(--err); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }

/* Flash */
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-weight: 500; }
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.flash-warn { background: var(--warn-soft); color: var(--warn); }
.flash-err { background: var(--err-soft); color: var(--err); }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.narrow { max-width: 460px; margin: 24px auto; }

/* Hero + filters */
.hero { margin-bottom: 22px; }
.hero p { color: var(--ink-2); max-width: 560px; font-size: 1.05rem; }
.filters { display: flex; gap: 14px; align-items: end; flex-wrap: wrap; margin-bottom: 22px; }
.filters label { display: flex; flex-direction: column; font-size: .8rem; font-weight: 600; color: var(--muted); gap: 4px; }
.filters select { min-width: 150px; }
.filters-count { margin-left: auto; color: var(--muted); font-size: .9rem; padding-bottom: 10px; }

/* Listings grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 22px; }
.listing { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: inherit; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s; display: flex; flex-direction: column; }
.listing:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(31,42,46,.06), 0 14px 32px rgba(31,42,46,.10); }
.listing-img { aspect-ratio: 4 / 3; background: #ebe6dd; position: relative; }
.listing-img img { width: 100%; height: 100%; object-fit: cover; }
.listing-img .badge { position: absolute; top: 12px; left: 12px; }
.noimg { width: 100%; height: 100%; display: grid; place-items: center; color: var(--muted); font-size: .9rem; background: repeating-linear-gradient(45deg, #ebe6dd, #ebe6dd 10px, #e6e0d6 10px, #e6e0d6 20px); }
.listing-body { padding: 16px 18px 18px; }
.listing-rent { font-family: var(--serif); font-size: 1.5rem; font-weight: 650; }
.listing-rent span { font: 400 .9rem var(--sans); color: var(--muted); }
.listing-rent.big { font-size: 2rem; }
.listing-title { font-weight: 600; margin-top: 2px; }
.listing-meta { color: var(--ink-2); font-size: .93rem; }
.listing-addr { color: var(--muted); font-size: .9rem; }
.listing-avail { margin-top: 10px; font-size: .85rem; font-weight: 600; color: var(--accent); }

.empty { text-align: center; padding: 56px 16px; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }

/* Badges */
.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--bg); color: var(--ink-2); white-space: nowrap; }
.badge-new { background: #e3ecf7; color: #2a5389; }
.badge-reviewing { background: var(--warn-soft); color: var(--warn); }
.badge-approved, .badge-available { background: var(--ok-soft); color: var(--ok); }
.badge-denied { background: var(--err-soft); color: var(--err); }
.badge-pending { background: var(--warn-soft); color: var(--warn); }
.badge-rented, .badge-withdrawn, .badge-hidden { background: #ececec; color: #666; }

/* Property page */
.crumb { margin-bottom: 14px; }
.crumb a { text-decoration: none; font-weight: 500; }
.prop { display: grid; grid-template-columns: 1fr 360px; gap: 28px; align-items: start; }
.gallery-main { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: var(--radius); background: #ebe6dd; }
.thumbs { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; padding-bottom: 4px; }
.thumb { border: 2px solid transparent; padding: 0; border-radius: 8px; overflow: hidden; cursor: pointer; flex: 0 0 88px; height: 64px; background: none; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.active { border-color: var(--accent); }
.prop-side { position: sticky; top: 84px; }
.prop-title { font-size: 1.4rem; margin-top: 8px; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 18px 0 22px; }
.facts div { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.facts .wide { grid-column: 1 / -1; }
.facts dt { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.facts dd { margin: 0; font-weight: 600; }
.prop-desc { max-width: 720px; margin-top: 34px; }
.prop-desc h2 { margin-top: 1.2em; }
.features { columns: 2; padding-left: 1.1em; color: var(--ink-2); }
.features li { margin-bottom: 4px; break-inside: avoid; }

/* Forms */
input, select, textarea { width: 100%; font: inherit; color: inherit; background: var(--surface); border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input:disabled { background: var(--bg); color: var(--muted); }
textarea { resize: vertical; min-height: 84px; }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent); }
input.file { padding: 10px; background: var(--bg); border-style: dashed; }
.form-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 16px 18px; }
.field { grid-column: span 6; min-width: 0; }
.field.half { grid-column: span 3; }
.field.third { grid-column: span 2; }
.field label, .field legend { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 6px; color: var(--ink); }
.field fieldset { border: 0; margin: 0; padding: 0; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { display: inline-flex !important; align-items: center; gap: 8px; font-weight: 500 !important; background: var(--bg); border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 14px; cursor: pointer; margin: 0 !important; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.req { color: var(--err); }
.help { display: block; color: var(--muted); font-size: .83rem; margin-top: 5px; }
.error { display: block; color: var(--err); font-size: .85rem; font-weight: 500; margin-top: 5px; }
.has-error input, .has-error select, .has-error textarea, .has-error-js input, .has-error-js select, .has-error-js textarea { border-color: var(--err); }
.has-error .choice { border-color: #e7b6ad; }
.hp { position: absolute; left: -9999px; height: 0; overflow: hidden; }

/* Occupants table */
.people { display: grid; gap: 8px; }
.people-row { display: grid; grid-template-columns: repeat(13, 1fr); gap: 8px; }
.people-row > * { grid-column: span var(--w); min-width: 0; }
.people-head span { font-size: .78rem; font-weight: 600; color: var(--muted); }
.people-add { justify-self: start; margin-top: 4px; }
.eho { font-size: .85rem; color: var(--ink-2); display: flex; gap: 10px; align-items: flex-start; }
.eho-mark { font-size: 1.4rem; line-height: 1; }
.legal { margin-bottom: 1em; }

/* Admin secrets + mini tables */
.secret { font-family: ui-monospace, Menlo, monospace; letter-spacing: .03em; }
.reveal { font: 600 .75rem var(--sans); background: var(--accent-soft); color: var(--accent); border: 0; border-radius: 6px; padding: 2px 8px; cursor: pointer; margin-left: 4px; }
table.mini { font-size: .88rem; border: 1px solid var(--line); border-radius: 8px; }
table.mini th, table.mini td { padding: 6px 10px; }

/* Application page */
.apply { max-width: 780px; margin: 0 auto; }
.apply-head { margin-bottom: 20px; }
.note { background: var(--warn-soft); color: var(--warn); padding: 10px 14px; border-radius: 10px; font-size: .93rem; }
.section { margin-bottom: 18px; }
.section h2 { font-size: 1.15rem; }
.legal { font-size: .9rem; color: var(--ink-2); background: var(--bg); padding: 14px; border-radius: 10px; }
.signature { font-family: var(--serif); font-size: 1.15rem; font-style: italic; }
.submit-bar { display: flex; justify-content: flex-end; margin-top: 8px; }

.thanks .check { width: 64px; height: 64px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; font-size: 2rem; margin: 0 auto 14px; }
.ref { font-family: ui-monospace, Menlo, monospace; background: var(--bg); padding: 2px 8px; border-radius: 6px; letter-spacing: .05em; }

/* ---------- Admin ---------- */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; text-decoration: none; color: inherit; box-shadow: var(--shadow); }
.stat-n { font-family: var(--serif); font-size: 2rem; font-weight: 650; line-height: 1.1; }
.stat-l { color: var(--muted); font-size: .88rem; font-weight: 500; }
.stat.hl { border-color: #b9d0c4; background: var(--accent-soft); }

.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: .94rem; }
th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 12px 14px; border-bottom: 1px solid var(--line); background: #fbfaf7; white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: #fbfaf7; }
td a.rowlink { color: var(--ink); font-weight: 600; text-decoration: none; }
.thumb-sm { width: 64px; height: 48px; border-radius: 6px; object-fit: cover; background: #ebe6dd; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a { text-decoration: none; padding: 7px 14px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); font-size: .9rem; font-weight: 500; }
.tabs a.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.tabs .count { opacity: .7; margin-left: 4px; }
.searchbar { display: flex; gap: 8px; margin-bottom: 16px; max-width: 420px; }

.app-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 22px; align-items: start; }
.app-side { position: sticky; top: 84px; display: grid; gap: 16px; }
.answers h2 { font-size: 1.05rem; padding-bottom: 8px; border-bottom: 1px solid var(--line); margin-top: 6px; }
.answers dl { display: grid; grid-template-columns: 220px 1fr; gap: 8px 16px; margin: 0 0 22px; }
.answers dt { color: var(--muted); font-size: .9rem; }
.answers dd { margin: 0; min-width: 0; overflow-x: auto; }
.answers dl { grid-template-columns: 220px minmax(0, 1fr); }
.flag { color: var(--warn); }
.doclist { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.doclist a { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--ink); }
.doclist a:hover { background: var(--bg); }
.doclist .ext { font: 700 .7rem var(--sans); background: var(--accent-soft); color: var(--accent); border-radius: 6px; padding: 4px 6px; text-transform: uppercase; }
.doclist small { color: var(--muted); display: block; }
.ratio { font-size: .85rem; color: var(--muted); }
.ratio strong { color: var(--ink); }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.photo-item { position: relative; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--surface); }
.photo-item img { width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.photo-item .photo-actions { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px; font-size: .8rem; }
.photo-item .cover-tag { position: absolute; top: 6px; left: 6px; background: var(--accent); color: #fff; font-size: .7rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; }
.photo-item form { display: inline; }

@media print {
  .topbar, .footer, .app-side form, .no-print { display: none !important; }
  .app-layout { grid-template-columns: 1fr; }
  .card { box-shadow: none; border: 0; padding: 0; }
  body { background: #fff; }
}

@media (max-width: 860px) {
  .prop, .app-layout { grid-template-columns: 1fr; }
  .prop-side, .app-side { position: static; }
  .answers dl { grid-template-columns: 1fr; gap: 2px; }
  .answers dd { margin-bottom: 10px; }
}
@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
  .field, .field.half, .field.third { grid-column: 1 / -1; }
  .people-head { display: none !important; }
  .people-row { grid-template-columns: 1fr 1fr !important; padding: 10px; border: 1px solid var(--line); border-radius: 10px; }
  .people-row input { grid-column: auto !important; }
  .card { padding: 18px; }
  .features { columns: 1; }
  .submit-bar .btn { width: 100%; }
  .topbar-inner { padding-top: 10px; padding-bottom: 10px; }
  .filters-count { margin-left: 0; }
  .hide-sm { display: none; }
}
