:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --ink: #14213d;
  --ink-2: #4a5468;
  --ink-3: #8a93a6;
  --line: #e3e6ee;
  --primary: #14213d;
  --accent: #e07a2f;
  --accent-soft: #fdf0e6;
  --ok: #1f8a5b;
  --ok-soft: #e5f4ec;
  --wa: #1fa855;
  --danger: #c0392b;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20,33,61,.06), 0 4px 16px rgba(20,33,61,.06);
  --font: 'Heebo', 'Segoe UI', Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
a { color: inherit; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 10px;
  padding: 9px 16px; font-weight: 600; cursor: pointer; background: transparent; text-decoration: none; white-space: nowrap; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #1f3260; }
.btn-outline { border-color: var(--line); background: var(--surface); }
.btn-outline:hover { border-color: var(--ink-3); }
.btn-ghost { color: var(--ink-2); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-call { background: var(--primary); color: #fff; }
.btn-wa { background: var(--wa); color: #fff; }
.icon-btn { border: 0; background: transparent; font-size: 18px; cursor: pointer; width: 36px; height: 36px; border-radius: 50%; color: var(--ink-2); }
.icon-btn:hover { background: var(--bg); }
.badge { background: var(--accent); color: #fff; border-radius: 999px; font-size: 12px; padding: 0 7px; min-width: 20px; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; }
.brand-mark { background: var(--accent); color: #fff; border-radius: 8px; padding: 2px 8px; font-size: 14px; letter-spacing: .5px; }
.brand-name { font-size: 17px; }
.brand-lg .brand-mark { font-size: 18px; padding: 4px 10px; }
.brand-lg .brand-name { font-size: 22px; }

/* ---------- login ---------- */
.login-view { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 500px at 80% -10%, #22345e 0%, var(--primary) 55%); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 16px; padding: 28px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login-sub { color: var(--ink-3); margin: 6px 0 20px; }
.login-help { color: var(--ink-3); font-size: 13px; margin: 14px 0 0; text-align: center; }
.form-error { color: var(--danger); min-height: 1.2em; margin: 10px 0 0; font-size: 14px; }

/* ---------- fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field input, .field select, .sort select {
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; background: var(--surface); min-width: 0; width: 100%; }
.field input:focus, .field select:focus, .sort select:focus { outline: 2px solid #c9d3ea; border-color: #9aa8c7; }
.range { display: flex; align-items: center; gap: 8px; }
.range > span { color: var(--ink-3); font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 11px; font-size: 13px; cursor: pointer; }
.chip.is-on { background: var(--primary); border-color: var(--primary); color: #fff; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; font-size: 14px; }
.checks label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.checks input { width: 17px; height: 17px; accent-color: var(--primary); }

/* ---------- topbar ---------- */
.topbar { position: sticky; top: 0; z-index: 30; background: var(--primary); color: #fff; display: flex; align-items: center;
  gap: 20px; padding: 0 20px; height: 60px; }
.tabs { display: flex; gap: 4px; height: 100%; }
.tab { border: 0; background: transparent; color: #c5cde0; padding: 0 14px; font-weight: 600; cursor: pointer; border-bottom: 3px solid transparent; }
.tab:hover { color: #fff; }
.tab.is-active { color: #fff; border-bottom-color: var(--accent); }
.tab-count { font-size: 12px; opacity: .75; font-weight: 500; }
.tab-admin { color: #ffcfa6; }
.user-box { margin-inline-start: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; }
.user-email { color: #c5cde0; }
.user-box .btn-ghost { color: #fff; }
.user-box .btn-ghost:hover { background: rgba(255,255,255,.1); }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 260px 1fr; gap: 20px; padding: 20px; max-width: 1600px; margin: 0 auto; align-items: start; }
.filters { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); position: sticky; top: 80px;
  max-height: calc(100vh - 100px); display: flex; flex-direction: column; }
.filters-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.filters-head h2 { font-size: 16px; margin: 0; }
.filters-body { padding: 16px; overflow-y: auto; }
.results { min-width: 0; }
.results-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.results-count { font-weight: 600; color: var(--ink-2); }
.sort { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.sort select { width: auto; }
.status { color: var(--ink-3); padding: 8px 0; }
.status:empty { display: none; }
.more-wrap { text-align: center; padding: 16px; }
.only-mobile { display: none !important; }

/* ---------- table ---------- */
.table-wrap { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
.table-wrap:empty { display: none; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { position: sticky; top: 0; background: #f8f9fc; color: var(--ink-2); font-weight: 600; text-align: right; padding: 10px 7px;
  border-bottom: 1px solid var(--line); white-space: nowrap; font-size: 13px; }
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { color: var(--ink); }
th .arrow { font-size: 10px; margin-inline-start: 3px; }
td { padding: 10px 7px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f6f8fd; }
td.num { font-variant-numeric: tabular-nums; }
td.price { font-weight: 700; }
td.addr { font-weight: 600; max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
td.broker { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.card-actions .btn-sm { padding: 6px 10px; }
td.desc { white-space: normal; min-width: 320px; max-width: 560px; color: var(--ink-2); }
td.muted, .muted { color: var(--ink-3); }
.tag { display: inline-block; font-size: 12px; border-radius: 6px; padding: 1px 7px; background: var(--bg); color: var(--ink-2); }
.tag-new { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-warn { background: #fdecea; color: var(--danger); font-weight: 600; }

/* ---------- cards (mobile) ---------- */
.cards { display: none; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; cursor: pointer; }
.card-price { font-size: 20px; font-weight: 800; }
.card-ppsqm { font-size: 12px; color: var(--ink-3); }
.card-addr { font-weight: 700; margin-top: 2px; }
.card-sub { color: var(--ink-2); font-size: 14px; }
.card-facts { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.card-broker { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line); padding-top: 10px; }
.card-broker .name { font-size: 13px; color: var(--ink-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-actions { display: flex; gap: 6px; flex-shrink: 0; }
.card-desc { color: var(--ink-2); font-size: 14px; white-space: pre-line; margin: 6px 0 10px; }

/* ---------- favorites / toast / notice ---------- */
.star { border: 0; background: transparent; cursor: pointer; font-size: 20px; line-height: 1; color: #c3c9d6; padding: 2px 4px; }
.star:hover { color: var(--accent); }
.star.is-on { color: var(--accent); }
th.star-col, td.star-col { width: 34px; padding-inline: 6px 0; text-align: center; }
.card-head { display: flex; align-items: flex-start; gap: 6px; }
.fav-filter { grid-column: 1 / -1; color: var(--accent); font-weight: 600; }
.toast { position: fixed; z-index: 80; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow); max-width: calc(100% - 32px); font-size: 14px; text-align: center; }
.notice-card { max-width: 520px; }
.notice-card h2 { margin: 0 0 12px; font-size: 21px; }
.notice-card p { margin: 0 0 10px; color: var(--ink-2); }
.notice-check { display: flex; align-items: center; gap: 8px; margin: 16px 0 14px; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.notice-check input { width: 17px; height: 17px; accent-color: var(--primary); }
.m-star { position: absolute; top: 12px; left: 52px; font-size: 24px; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(20,33,61,.45); display: grid; place-items: center; padding: 16px; }
.modal-card { position: relative; background: var(--surface); border-radius: 16px; width: 100%; max-width: 720px; max-height: 90vh; overflow-y: auto; padding: 24px; }
.modal-close { position: absolute; top: 12px; left: 12px; }
.m-head { padding-inline-end: 0; padding-left: 40px; }
.m-code { color: var(--ink-3); font-size: 13px; }
.m-title { font-size: 22px; font-weight: 800; margin: 2px 0; }
.m-sub { color: var(--ink-2); }
.m-price { font-size: 26px; font-weight: 800; margin-top: 10px; }
.m-grid { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin: 18px 0; }
.m-grid div { padding: 9px 12px; border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); margin-bottom: -1px; }
.m-grid dt { font-size: 12px; color: var(--ink-3); }
.m-grid dd { margin: 0; font-weight: 600; }
.m-notes h3, .m-broker h3 { font-size: 14px; color: var(--ink-2); margin: 0 0 6px; }
.m-notes p { white-space: pre-line; margin: 0; background: #fafbfd; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.m-broker { margin-top: 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--bg); border-radius: 10px; padding: 12px 14px; }
.m-broker .who { font-weight: 700; }
.m-broker .office { color: var(--ink-2); font-size: 13px; }
.m-admin { margin-top: 18px; border: 1px dashed #f0b98c; background: #fffaf5; border-radius: 10px; padding: 12px 14px; font-size: 14px; }
.m-admin h3 { font-size: 13px; color: var(--accent); margin: 0 0 6px; }

.boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); color: var(--ink-3); z-index: 100; }
.backdrop { display: none; }

@media (max-width: 1500px) { .opt { display: none; } table { font-size: 13.5px; } }

.feedback-btn { color: #ffcfa6 !important; }
.notice-card a { color: var(--accent); font-weight: 600; }

.notice-rules { margin: 0 0 10px; padding-inline-start: 20px; color: var(--ink); }
.notice-rules li { margin-bottom: 6px; }
.notice-grace { background: var(--accent-soft); color: #9a4d12 !important; border-radius: 8px; padding: 8px 12px; font-size: 14px; }
.region-card { max-width: 520px; }
.region-chips { margin: 4px 0 14px; }
.region-chips .chip { font-size: 14px; padding: 8px 14px; }
.region-other { font-size: 13px; color: var(--ink-3); margin: 0 0 16px; }
.region-other a { color: var(--accent); font-weight: 600; }
.v-when { font-weight: 700; white-space: nowrap; }
.v-when small { display: block; font-weight: 500; color: var(--ink-3); }
.rsvp { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.rsvp.is-on { background: var(--ok-soft); border-color: #b9dfca; color: var(--ok); }
.rsvp-count { font-size: 12px; color: var(--ink-3); margin-inline-start: 6px; white-space: nowrap; }
.card-when { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  body { font-size: 15px; }
  .only-mobile { display: inline-flex !important; }
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 16px 0; gap: 8px; }
  .brand-name { font-size: 15px; }
  .user-email { display: none; }
  .fb-label { display: none; }
  .tabs { order: 3; width: 100%; height: 44px; overflow-x: auto; margin: 0 -16px; padding: 0 8px; width: calc(100% + 32px); }
  .tab { flex-shrink: 0; padding: 0 12px; }
  .layout { display: block; padding: 12px 16px; }
  .filters { position: fixed; z-index: 50; inset: auto 0 0 0; top: auto; max-height: 88vh; border-radius: 18px 18px 0 0;
    transform: translateY(105%); transition: transform .25s ease; }
  .filters.is-open { transform: translateY(0); }
  .filters-foot { display: block !important; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
  .backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(20,33,61,.4); display: block; }
  .results-bar { flex-wrap: wrap; }
  .sort span { display: none; }
  .table-wrap { display: none; }
  .cards { display: block; }
  .modal { padding: 0; align-items: end; }
  .modal-card { border-radius: 18px 18px 0 0; max-height: 92vh; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
  .m-grid { grid-template-columns: repeat(2, 1fr); }
  .m-broker .card-actions { width: 100%; }
  .m-broker .card-actions .btn { flex: 1; }
}
