:root {
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f6f7f9;
  --card: #ffffff;
  --accent: #2563eb;
  --accent-ink: #1d4ed8;
  --good: #15803d;
  --good-bg: #dcfce7;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --bad: #b91c1c;
  --bad-bg: #fee2e2;
  --info-bg: #e0e7ff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .06);
  font-family: ui-sans-serif, -apple-system, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; margin: 0 0 8px; }
h1 { font-size: 26px; margin: 0 0 6px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 28px 0 12px; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 8px; }
small { font-weight: 400; color: var(--muted); font-size: 12px; text-transform: none; letter-spacing: 0; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 18px;
  height: 56px; padding: 0 18px; background: var(--ink); color: #fff;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.brand-lg { font-size: 22px; }
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 0 rgba(34,197,94,.6); animation: ping 2.4s infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(34,197,94,.55);} 70% { box-shadow: 0 0 0 10px rgba(34,197,94,0);} 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0);} }
.tabs { display: flex; gap: 2px; overflow-x: auto; }
.tabs button { background: none; border: 0; color: #cbd5e1; padding: 8px 12px; border-radius: 8px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.tabs button.active, .tabs button:hover { color: #fff; background: rgba(255,255,255,.1); }
.status-pill { margin-left: auto; font-size: 12px; padding: 5px 10px; border-radius: 999px; background: rgba(255,255,255,.1); white-space: nowrap; }
.status-pill.warn { background: #b45309; }
.status-pill.bad { background: #b91c1c; }
.logout { margin: 0; }
.topbar .btn-ghost { color: #cbd5e1; border-color: rgba(255,255,255,.2); }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 9px; padding: 9px 14px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-weight: 600; font-size: 14px; }
.btn:hover { border-color: #cbd5e1; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); }
.btn-good { background: var(--good); border-color: var(--good); color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--ink-2); margin-bottom: 12px; }
.field.inline { flex-direction: row; align-items: center; gap: 10px; }
.field.inline input { width: 90px; }
.field input, .field textarea, .select, .search {
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; background: #fff; font-size: 14px; width: 100%;
}
.field input:focus, .field textarea:focus, .select:focus, .search:focus { outline: 2px solid #bfdbfe; border-color: var(--accent); }
.switch-row { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; margin: 8px 0; cursor: pointer; }
.switch-row input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); }
.switch-row.big { background: var(--warn-bg); border-radius: 10px; padding: 10px 12px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 12px; }
.checks label { display: flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.checks input { accent-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 11px; font-size: 13px; cursor: pointer; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.lines { display: grid; grid-template-columns: repeat(auto-fill, 30px); gap: 6px; margin-bottom: 10px; }
.line { width: 30px; height: 30px; border-radius: 50%; border: 0; color: #fff; font-weight: 700; font-size: 14px; cursor: pointer; opacity: .35; }
.line.on { opacity: 1; box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ink); }
.line.dark { color: #111; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }

/* listings layout */
.view { min-height: calc(100vh - 56px); }
#view-listings { display: grid; grid-template-columns: 300px 1fr; }
.filters { background: #fff; border-right: 1px solid var(--line); padding: 16px 18px 40px; height: calc(100vh - 56px); position: sticky; top: 56px; overflow-y: auto; }
.filters-head { display: flex; align-items: center; gap: 8px; }
.filters-head h2 { margin: 0; margin-right: auto; }
.fgroup { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 2px; }
.results { padding: 16px 20px 40px; min-width: 0; }
.results-bar { display: flex; gap: 10px; align-items: center; }
.results-bar .search { flex: 1; }
.results-bar .select { width: auto; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: none; padding: 8px 14px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--ink-2); }
.seg button.active { background: var(--ink); color: #fff; }
.results-meta { display: flex; justify-content: space-between; margin: 14px 2px 10px; font-size: 13px; color: var(--ink-2); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.lcard { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; cursor: pointer; border: 1px solid transparent; }
.lcard:hover { border-color: #cbd5e1; }
.lcard.fresh { border-color: #22c55e; }
.lcard .photo { height: 132px; background: #e2e8f0 center/cover no-repeat; position: relative; }
.lcard .photo .ph { position: absolute; inset: 0; display: grid; place-items: center; color: #94a3b8; font-weight: 700; font-size: 13px; letter-spacing: .05em; text-transform: uppercase; }
.lcard .photo .badge-top { position: absolute; left: 10px; top: 10px; }
.lcard .photo.nophoto { height: 44px; }
.lcard .photo.nophoto .ph { color: rgba(255,255,255,.9); justify-content: end; padding-right: 14px; font-size: 11.5px; }
.photo.nophoto[data-src=reside] { background: #0f766e; }
.photo.nophoto[data-src=hdc] { background: #4338ca; }
.photo.nophoto[data-src=agents] { background: #475569; }
.photo.nophoto[data-src=housing_connect] { background: #1d4ed8; }
.photo.nophoto[data-src=nys] { background: #7e22ce; }
.lcard .photo.nophoto .badge-top { top: 10px; }
.lcard .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.lcard .title { font-weight: 700; font-size: 15px; line-height: 1.3; }
.lcard .area { font-size: 13px; color: var(--muted); }
.lcard .rent { font-size: 14px; font-weight: 600; }
.lcard .foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 6px; }
.lcard .when { font-size: 12px; color: var(--muted); }
.badges { display: flex; flex-wrap: wrap; gap: 5px; }
.badge { font-size: 11.5px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: #f1f5f9; color: var(--ink-2); white-space: nowrap; }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: #3730a3; }
.badge.dark { background: var(--ink); color: #fff; }
.reasons { font-size: 12px; color: var(--muted); }
.empty { padding: 50px 20px; text-align: center; color: var(--muted); background: #fff; border-radius: var(--radius); }
.map { height: calc(100vh - 170px); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.pin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); }

/* drawer */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.35); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); background: #fff; z-index: 50; overflow-y: auto; box-shadow: -8px 0 30px rgba(15,23,42,.15); }
.drawer .hero { height: 200px; background: #e2e8f0 center/cover no-repeat; position: relative; }
.drawer .close { position: absolute; top: 12px; right: 12px; background: rgba(15,23,42,.7); color: #fff; border: 0; border-radius: 50%; width: 34px; height: 34px; font-size: 18px; cursor: pointer; }
.drawer .inner { padding: 18px 20px 40px; }
.drawer h1 { font-size: 22px; }
.drawer .actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 14px; margin: 12px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.desc { white-space: pre-wrap; font-size: 14px; color: var(--ink-2); line-height: 1.5; }
.app-box { border-radius: 10px; padding: 12px 14px; margin: 10px 0; font-size: 14px; }
.app-box.good { background: var(--good-bg); }
.app-box.warn { background: var(--warn-bg); }
.app-box.bad { background: var(--bad-bg); }
.app-box.info { background: var(--info-bg); }
.shot { margin-top: 8px; max-width: 100%; border-radius: 8px; border: 1px solid var(--line); }

/* pages */
.page { max-width: 1100px; margin: 0 auto; padding: 24px 20px 120px; }
.table-wrap { overflow-x: auto; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table input[type=number] { width: 80px; border: 1px solid var(--line); border-radius: 7px; padding: 5px 7px; }
.source-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-top: 18px; }
.scard { background: #fff; border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); font-size: 14px; display: flex; flex-direction: column; gap: 4px; }
.scard .name { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #94a3b8; display: inline-block; }
.dot.good { background: #22c55e; } .dot.bad { background: #ef4444; } .dot.warn { background: #f59e0b; }
.scard .err { color: var(--bad); font-size: 12px; word-break: break-word; }
.scard .btn { margin-top: 6px; align-self: flex-start; }
.log { list-style: none; padding: 0; margin: 0; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); font-size: 13px; }
.log li { padding: 8px 14px; border-bottom: 1px solid #f1f5f9; display: grid; grid-template-columns: 90px 110px 1fr; gap: 10px; }
.log li.error { background: #fff5f5; } .log li.warn { background: #fffbeb; }
.card-block { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px 20px 18px; margin-top: 18px; }
.radio-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.radio-card { border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; font-size: 14px; }
.radio-card span { color: var(--muted); font-size: 13px; }
.radio-card input { display: none; }
.radio-card:has(input:checked) { border-color: var(--accent); background: #eff6ff; }
.save-bar { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,.95); border-top: 1px solid var(--line); padding: 12px 20px; display: flex; justify-content: flex-end; align-items: center; gap: 14px; z-index: 20; backdrop-filter: blur(6px); }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 60; font-size: 14px; box-shadow: var(--shadow); max-width: 90vw; }

/* login */
.login-body { display: grid; place-items: center; min-height: 100vh; background: var(--ink); }
.login-card { background: #fff; padding: 30px 28px; border-radius: 16px; width: min(360px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-card .muted { margin: 4px 0 20px; }
.login-error { color: var(--bad); min-height: 18px; font-size: 13px; margin: 0 0 10px; }

.only-mobile { display: none; }
@media (max-width: 860px) {
  body { padding-bottom: calc(62px + env(safe-area-inset-bottom)); }
  .topbar { gap: 10px; padding: 0 12px; }
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; background: var(--ink); justify-content: space-around;
          padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); border-top: 1px solid rgba(255,255,255,.08); }
  .tabs button { flex: 1; padding: 10px 4px; font-size: 13px; }
  .save-bar { bottom: calc(58px + env(safe-area-inset-bottom)); }
  .status-pill { font-size: 11px; padding: 4px 8px; }
  .logout { display: none; }
  #view-listings { display: block; }
  .filters { position: fixed; inset: 56px 0 0 0; height: auto; z-index: 35; transform: translateX(-100%); transition: transform .2s; }
  .filters.open { transform: none; }
  .only-mobile { display: inline-flex; }
  .results { padding: 12px; }
  .results-bar { flex-wrap: wrap; }
  .results-bar .search { order: 5; flex-basis: 100%; }
  .cards { grid-template-columns: 1fr; }
  .map { height: calc(100vh - 210px); }
  .grid2, .radio-cards { grid-template-columns: 1fr; }
  .log li { grid-template-columns: 70px 1fr; }
  .log li .src { display: none; }
  .kv { grid-template-columns: 110px 1fr; }
}
