/* 12-responsive.css — Breakpoints for everything above, and the phone shell: app bar, bottom tabs,
   slide-out menu, filters folded behind one button, tables as cards.
   Part of the CRM stylesheet: the files load in number order (components/app_styles.html) and later
   rules win, exactly as when this was one file. */

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .dash-grid { grid-template-columns: 240px minmax(0, 1fr); }
  .dash-grid > :last-child { grid-column: 1 / -1; }
  .grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .leader { grid-template-columns: 26px minmax(0, 1.6fr) repeat(4, minmax(0, 1fr)) 90px; }
  .leader .hide-md { display: none; }
}
@media (max-width: 1024px) {
  .detail-layout { grid-template-columns: minmax(0, 1fr); }
  .grid-6, .grid-5, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth { grid-template-columns: minmax(0, 1fr); } .auth-art { display: none; }
}
@media (max-width: 820px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-100%); width: 240px; transition: transform .2s; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .panel { padding: 18px 14px 30px; border-radius: 0; }
  .dash-grid, .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .form-grid, .form-grid.cols-3, .form-grid.cols-4 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .spec-grid, .check-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .public-selection { width: min(100% - 20px, 640px); padding-top: 10px; }
  .public-selection-head { align-items: flex-start; flex-direction: column; gap: 14px; }
  .public-selection-head h1 { font-size: 21px; }
  .public-broker { align-items: flex-start; flex-wrap: wrap; }
  .public-broker .btn { width: 100%; }
  .public-property { grid-template-columns: minmax(0, 1fr); }
  .public-property-cover { height: 230px; }
  .public-property-info { padding: 17px; }
  .public-more { align-self: stretch; justify-content: center; }
  .public-slide { height: 52vh; }
  .public-detail-body { padding: 16px; }
  .public-detail-title { flex-direction: column; gap: 6px; }
  .public-detail-price { align-items: flex-start; text-align: left; }
}

.mini-app { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; min-height: 100vh; padding: 24px; text-align: center; }

/* ---------- Phone shell: app bar, bottom tabs, slide-out menu ---------- */
.topbar-brand, .topbar-mobile, .tabbar, .sidebar-prefs, .sidebar-backdrop, .filters-toggle, .menu-btn { display: none; }
.topbar-brand img { display: block; height: 21px; width: auto; }
.topbar-brand .logo-dark, [data-theme=dark] .topbar-brand .logo-light { display: none; }
[data-theme=dark] .topbar-brand .logo-dark { display: block; }

@media (max-width: 820px) {
  /* Things scrolled into view (anchors, the first form error) land below the sticky top bar, not under it. */
  html { scroll-padding-top: calc(64px + var(--tg-safe-top, 0px)); }
  .topbar { position: sticky; top: 0; z-index: 30; height: 52px; padding: 0 12px; justify-content: flex-start; gap: 4px; background: color-mix(in srgb, var(--surface) 92%, transparent); border-bottom: 1px solid var(--border-soft); backdrop-filter: blur(14px); }
  .topbar-brand { display: flex; margin-right: auto; }
  .topbar-desktop { display: none !important; }
  .topbar-mobile { display: grid; }
  .topbar .icon-btn { width: 38px; height: 38px; }
  .main { background: var(--surface); }
  .panel { border: 0; padding-bottom: calc(92px + env(safe-area-inset-bottom)); }
  body.has-selection-bar .panel { padding-bottom: calc(160px + env(safe-area-inset-bottom)); }

  .sidebar { z-index: 50; width: min(300px, 84vw); padding-top: calc(18px + env(safe-area-inset-top)); padding-bottom: calc(12px + env(safe-area-inset-bottom)); overflow-y: auto; }
  .sidebar .nav-link { padding-top: 10px; padding-bottom: 10px; font-size: 14px; }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 45; display: block; background: rgba(15, 23, 42, .4); opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.nav-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .sidebar-prefs { display: flex; align-items: center; justify-content: space-between; margin: auto 2px 10px; padding-top: 12px; border-top: 1px solid var(--border-soft); }

  .tabbar { position: fixed; z-index: 35; inset: auto 0 0 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--surface) 94%, transparent); border-top: 1px solid var(--border); backdrop-filter: blur(14px); }
  .tabbar a, .tabbar button { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 0 2px; border: 0; background: none; color: var(--muted); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .tabbar svg { width: 22px; height: 22px; }
  .tabbar .active { color: var(--accent-strong); }
  .tabbar-badge { position: absolute; top: 0; left: calc(50% + 6px); min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--danger); color: #fff; font-size: 10.5px; font-style: normal; font-weight: 700; line-height: 16px; text-align: center; }

  .selection-bar { left: 10px; right: 10px; bottom: calc(70px + env(safe-area-inset-bottom)); transform: none; }
  .selection-bar > span { margin-right: auto; }
  .drawer, .drawer.wide { width: 100vw; }
}

/* ---------- Phone content ---------- */
@media (max-width: 640px) {
  .panel { padding-left: 12px; padding-right: 12px; padding-top: 14px; }
  .page-head { flex-direction: column; gap: 12px; margin-bottom: 14px; }
  .page-title { font-size: 20px; line-height: 1.2; }
  .page-sub { font-size: 14px; }
  .page-actions { width: 100%; }
  .page-actions > .segmented { display: flex; width: 100%; }
  .page-actions > .segmented > * { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 4px; text-align: center; padding: 7px 6px; }
  .page-actions > .btn, .page-actions > a.btn { flex: 1; justify-content: center; height: 40px; }
  .page-actions > .select, .page-actions > select { flex: 1; height: 38px; }

  /* Summary numbers: one swipeable row instead of a screen-high grid. */
  .grid:has(> .stat) { display: flex; gap: 8px; margin-left: -12px; margin-right: -12px; padding: 0 12px 2px; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: 12px; scrollbar-width: none; }
  .grid:has(> .stat)::-webkit-scrollbar { display: none; }
  .grid:has(> .stat) > .stat { flex: 0 0 auto; min-width: 132px; scroll-snap-align: start; }
  .stat-value { font-size: 20px; }

  /* Filters: the search box stays, everything else folds behind one button. */
  form[data-collapsible] { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; padding: 0; border: 0; background: none; }
  form[data-collapsible] .toolbar { display: contents; }
  form[data-collapsible] .input, form[data-collapsible] .select { flex: 1 1 calc(50% - 4px); width: auto; min-width: 0; max-width: none; height: 40px; }
  form[data-collapsible] input[name=q] { order: -1; flex: 1 1 0; }
  form[data-collapsible] .filters-toggle { order: -1; display: inline-flex; height: 40px; }
  .filters-toggle b { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 12.5px; line-height: 18px; }
  form[data-collapsible]:not(.filters-open) :is(select, .select, input:not([type=hidden]):not([name=q]), .btn-ghost, .search-select) { display: none; }
  form[data-collapsible] .spacer { display: none; }

  /* Tables read as a list of cards. */
  .table-wrap { border: 0; border-radius: 0; background: none; }
  .table-scroll { overflow: visible; }
  .table thead { display: none; }
  .table, .table tbody { display: block; }
  .table tr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 8px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
  .table td { height: auto; padding: 0; border: 0; font-size: 14px; }
  .table td:first-child { flex: 1 1 100%; }
  .table .hide-sm { display: none; }

  .property-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .property-picker { right: 40px; top: 6px; width: 32px; height: 32px; place-items: center; }
  .property-picker span { width: 24px; height: 24px; }
  .board { grid-auto-columns: 86vw; scroll-snap-type: x mandatory; scroll-padding-inline: 12px; margin-left: -12px; margin-right: -12px; padding: 0 12px 8px; }
  .board > * { scroll-snap-align: start; }
  .form-grid, .form-grid.cols-3, .form-grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
  .input, .select, textarea { font-size: 16px; } /* below 16px iOS zooms the page on focus */
  .messages { top: calc(60px + env(safe-area-inset-top)); width: calc(100% - 24px); }
}

@media (max-width: 640px) {
  /* With filters open the search box keeps the rest of its row; the other filters start below it. */
  form[data-collapsible] input[name=q] { flex: 1 1 55%; }
  .grid:has(> .stat) > .stat { min-width: 150px; }
  .grid:has(> .stat) .swatch, .grid:has(> .stat) .spark { display: none; }
  .gallery { grid-template-columns: minmax(0, 1fr); }
  .gallery .thumbs { grid-template-rows: none; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); height: 96px; }
  .image-manager { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .selection-bar { gap: 6px; padding-left: 14px; }
  .selection-bar > span { white-space: nowrap; }
  .selection-clear-label { display: none; }
}

.home-screen-btn { width: 100%; border: 0; background: var(--accent-soft); color: var(--accent-strong); font: inherit; cursor: pointer; }
.home-screen-btn[hidden] { display: none; }

