/* Bayti — app styles. Tokens first (the map kit reads --mk-*), then the screens. Mobile-first. */
:root {
  --primary: #0e7c86; --primary-soft: #e0f4f6; --surface: #ffffff; --bg: #f5f7fa; --text: #101828; --text-muted: #667085;
  --border: #e4e7ec; --danger: #d92d20; --radius: 14px; --shadow: 0 6px 20px rgba(16, 24, 40, .14); --touch: 44px;
  --mk-primary: var(--primary); --mk-surface: var(--surface); --mk-text: var(--text); --mk-text-muted: var(--text-muted); --mk-border: var(--border);
  /* the kit owns these: env() on iOS/web, real values pushed by the Android host */
  --safe-top: var(--mk-safe-top, 0px); --safe-bottom: var(--mk-safe-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 15px; line-height: 1.4; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.25; } h1 { font-size: 1.4rem; } h2 { font-size: 1.05rem; } h3 { font-size: 1rem; }
a { color: var(--primary); }
.muted { color: var(--text-muted); } .center { text-align: center; } .num { text-align: right; font-variant-numeric: tabular-nums; }
.app { min-height: 100dvh; }
.page-pad { padding: calc(var(--safe-top) + 16px) 16px calc(var(--mk-nav-height, 64px) + var(--safe-bottom) + 36px); max-width: 720px; margin: 0 auto; }

.btn { display: inline-flex; align-items: center; gap: 6px; min-height: var(--touch); padding: 0 16px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
.btn + .btn { margin-left: 8px; }
.icon-btn { width: var(--touch); height: var(--touch); display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; color: var(--text-muted); border-radius: 50%; cursor: pointer; }
.icon-btn.fav.on { color: var(--danger); } .icon-btn.fav.on svg { fill: currentColor; }

/* map screen */
/* The top bar lines up with the floating bottom bar: same max width, same 10px side gap. */
.map-top { position: fixed; top: calc(var(--safe-top) + 12px); left: 0; right: 0; z-index: 10; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 10px; pointer-events: none; }
.map-top > .search-bar { width: 100%; max-width: 560px; }
.search-bar { pointer-events: auto; display: flex; align-items: center; gap: 6px; height: 52px; padding: 0 8px 0 14px; background: var(--surface); border-radius: 999px; box-shadow: var(--shadow); color: var(--text-muted); }
.search-bar input { flex: 1; min-width: 0; border: 0; background: transparent; font: inherit; font-size: 1rem; color: var(--text); outline: none; }
.chip { min-height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; }
.chip.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.count-pill { pointer-events: none; align-self: center; background: rgba(255, 255, 255, .92); border-radius: 999px; padding: 4px 12px; font-size: .8rem; color: var(--text-muted); box-shadow: var(--shadow); }
.home.list-mode .map-layer { display: none; }
/* The list scrolls the page itself. It must not be a fixed-height flex column: .listing-card
   has overflow:hidden, so its automatic minimum size is 0, and once the 10px gaps alone exceed
   the container height every card is flex-shrunk to zero — 80 invisible cards on a phone-sized
   screen, which is exactly how the list view came back blank. Auto height in normal flow cannot
   shrink anything; flex: 0 0 auto on the children is the second belt. */
.list { max-width: 604px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; padding: calc(var(--safe-top) + 112px) 12px calc(var(--mk-nav-height, 64px) + var(--safe-bottom) + 24px); }
.list > * { flex: 0 0 auto; }
.filters { position: fixed; top: calc(var(--safe-top) + 112px); left: 0; right: 0; width: calc(100% - 20px); max-width: 560px; margin: 0 auto; z-index: 12; max-height: calc(100dvh - var(--mk-nav-height, 64px) - var(--safe-bottom) - var(--safe-top) - 150px); overflow-y: auto; }
.filters .label { display: block; font-size: .8rem; font-weight: 600; color: var(--text-muted); margin: 10px 0 4px; }
.filters .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.icon-btn.on { color: var(--primary); } .icon-btn .dot { position: absolute; transform: translate(12px, -12px); background: var(--primary); color: #fff; border-radius: 999px; font-size: 10px; min-width: 16px; height: 16px; line-height: 16px; text-align: center; padding: 0 3px; }
.search-bar .icon-btn { position: relative; flex: 0 0 auto; width: 40px; height: 40px; }
.map-overlay { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); background: rgba(255,255,255,.92); border-radius: 999px; padding: 3px 10px; font-size: .75rem; color: var(--text-muted); pointer-events: none; }
.mini-map { cursor: pointer; }

/* listing card */
.listing-card { display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.listing-card img { width: 100%; aspect-ratio: 5 / 3; object-fit: cover; display: block; cursor: pointer; }
.listing-card.compact { flex-direction: row; }
.listing-card.compact img { width: 120px; aspect-ratio: 1; }
.listing-card .body { flex: 1; min-width: 0; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.listing-card .row { display: flex; align-items: flex-start; gap: 6px; } .listing-card .row h3 { flex: 1; cursor: pointer; }
.listing-card .meta { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; } .listing-card .price { font-weight: 700; color: var(--primary); }
.listing-card .facts { display: flex; gap: 10px; font-size: .85rem; flex-wrap: wrap; } .listing-card .vr { display: inline-flex; align-items: center; gap: 3px; color: var(--primary); }
.listing-card .desc { margin: 4px 0; }
.listing-card .actions { display: flex; margin-top: 6px; } .listing-card.compact .actions { margin-top: auto; }
.listing-card.compact .actions .btn { min-height: 36px; padding: 0 12px; font-size: .85rem; }

/* details, dashboard, forms */
.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-top: 14px; }
.panel h2 { display: flex; align-items: center; gap: 6px; }
.mini-map { position: relative; height: 200px; border-radius: 10px; overflow: hidden; }
.back { margin-bottom: 8px; padding-left: 4px; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 12px 0; }
.kpi { background: var(--surface); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.kpi .v { font-size: 1.6rem; font-weight: 700; color: var(--primary); } .kpi .k { color: var(--text-muted); font-size: .85rem; }
.table { width: 100%; border-collapse: collapse; } .table th, .table td { padding: 8px 6px; border-bottom: 1px solid var(--border); text-align: left; } .table th { color: var(--text-muted); font-size: .85rem; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-weight: 600; font-size: .9rem; }
.field input, .field select, .field textarea { min-height: var(--touch); padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; font: inherit; font-weight: 400; background: var(--surface); }
.validation-message { color: var(--danger); font-size: .8rem; font-weight: 400; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 0 12px; } @media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.code { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 10px; overflow-x: auto; font-size: .8rem; }

/* auth, account, editor */
.page-pad.narrow { max-width: 440px; }
.btn.wide { width: 100%; justify-content: center; margin-top: 4px; }
.error { color: var(--danger); font-size: .9rem; }
.small { font-size: .85rem; }
.badge { display: inline-block; background: var(--primary-soft); color: var(--primary); border-radius: 999px; padding: 2px 10px; font-size: .75rem; font-weight: 600; vertical-align: middle; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.status { display: inline-block; border-radius: 999px; padding: 3px 10px; font-size: .75rem; font-weight: 600; background: var(--border); color: var(--text); white-space: nowrap; }
.status.s-2 { background: #fef3c7; color: #92400e; } .status.s-3 { background: #dcfce7; color: #166534; } .status.s-4 { background: #fee2e2; color: #991b1b; } .status.s-5, .status.s-6 { background: #e0e7ff; color: #3730a3; }
.banner { border-radius: 10px; padding: 10px 12px; margin: 10px 0; font-size: .95rem; }
.banner.warning { background: #fff7ed; border: 1px solid #fdba74; } .banner.info { background: #eff6ff; border: 1px solid #93c5fd; } .banner.success { background: #ecfdf5; border: 1px solid #6ee7b7; }
.mine-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); color: inherit; text-decoration: none; } .mine-row img { width: 64px; height: 48px; object-fit: cover; border-radius: 8px; } .mine-row .grow { flex: 1; min-width: 0; }
.pick-map { position: relative; height: 240px; border-radius: 10px; overflow: hidden; } .pick-map .crosshair { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -100%); color: var(--danger); pointer-events: none; filter: drop-shadow(0 2px 2px rgba(0,0,0,.4)); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; } .chip.static { cursor: default; margin: 2px 4px 2px 0; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin-bottom: 10px; }
.photo { position: relative; } .photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; border: 2px solid transparent; } .photo.cover img { border-color: var(--primary); }
.photo .mini { position: absolute; top: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(255,255,255,.92); cursor: pointer; font-size: 14px; } .photo .mini:first-of-type { left: 4px; } .photo .mini:last-of-type { right: 4px; }
.btn.upload { position: relative; overflow: hidden; } .btn.upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.gallery { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 12px; scroll-snap-type: x mandatory; } .gallery img { flex: 0 0 85%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius); scroll-snap-align: start; }

.note { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 12px; margin-bottom: 8px; cursor: pointer; border-left: 3px solid transparent; }
.note.unread { border-left-color: var(--primary); }
.note p { margin: 2px 0; }

.actions.center { justify-content: center; }

/* 360° tour — the viewer fills the screen and the chrome floats over it. The bottom bar is not
   rendered on this page, so the actions sit on the safe-area inset directly. */
.tour { position: fixed; inset: 0; background: #14161a; }
.tour-msg { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); color: #fff; text-align: center; width: 80%; }
.tour-msg-actions { position: absolute; left: 50%; top: 55%; transform: translateX(-50%); }
.tour-top { position: fixed; top: calc(var(--safe-top) + 10px); left: 10px; right: 10px; z-index: 12; display: flex; align-items: center; gap: 10px; pointer-events: none; }
.tour-top .icon-btn, .tour-top .tour-title { pointer-events: auto; }
.icon-btn.solid { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tour-title { display: flex; flex-direction: column; line-height: 1.2; background: rgba(255,255,255,.92); border-radius: 14px; padding: 6px 12px; box-shadow: var(--shadow); min-width: 0; }
.tour-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tour-note { position: fixed; left: 50%; top: calc(var(--safe-top) + 74px); transform: translateX(-50%); z-index: 12; max-width: 86%; margin: 0; background: rgba(255,255,255,.94); border-radius: 999px; padding: 6px 14px; font-size: .85rem; text-align: center; box-shadow: var(--shadow); }
.tour-bottom { position: fixed; left: 0; right: 0; bottom: calc(var(--safe-bottom) + 12px); z-index: 12; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 10px; pointer-events: none; }
.tour-rooms, .tour-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; max-width: 560px; pointer-events: auto; }
.tour-rooms .chip { background: rgba(255,255,255,.92); }
.tour-hint { margin: 0; color: rgba(255,255,255,.75); text-shadow: 0 1px 3px rgba(0,0,0,.6); }

/* tour editor: a sheet over the viewer, so the owner keeps seeing the room they are arranging */
.editor-sheet { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-bottom) + 10px); width: calc(100% - 20px); max-width: 560px; z-index: 12; max-height: 52dvh; overflow-y: auto; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; }
.editor-sheet .field { margin-bottom: 8px; }
.door-add { display: flex; gap: 8px; align-items: center; margin: 8px 0; flex-wrap: wrap; }
.door-add select { flex: 1; min-width: 150px; min-height: var(--touch); padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; font: inherit; background: var(--surface); }
.door-list { list-style: none; margin: 8px 0 0; padding: 0; }
.door-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.photo.pick { border: 0; background: none; padding: 0; cursor: pointer; }
.photo.pick:disabled { opacity: .6; cursor: default; }
.photo-tag { position: absolute; left: 4px; bottom: 4px; background: rgba(16,24,40,.75); color: #fff; border-radius: 999px; padding: 1px 8px; font-size: .7rem; font-weight: 700; }
.photo.pano img { border-color: var(--primary); }
