/* Final mobile layout rules: shared desktop density must not clip phone content. */
@media (max-width:800px){
  :root{--desa-mobile-header-height:calc(64px + env(safe-area-inset-top,0px))}
  html{scroll-padding-top:calc(var(--desa-mobile-header-height) + 16px)}
  .mobile-top{
    height:var(--desa-mobile-header-height)!important;
    padding:calc(8px + env(safe-area-inset-top,0px)) 14px 8px!important;
    box-sizing:border-box!important;background:#fff!important;
  }
  .mobile-logo{display:flex!important;align-items:center;flex:0 1 150px;min-width:0}
  .mobile-logo img{display:block!important;width:144px!important;height:auto!important;max-height:46px;object-fit:contain;filter:brightness(0);opacity:.85}
  .desktop-main{padding-top:calc(var(--desa-mobile-header-height) + 16px)!important;padding-bottom:calc(28px + env(safe-area-inset-bottom,0px))!important}
  .dashboard-welcome{flex-direction:column!important;align-items:stretch!important;gap:12px!important}
  .dashboard-actions{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;width:100%}
  .dashboard-actions .btn{min-width:0;white-space:normal}
  #dashboard .kpis{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:10px!important;background:transparent!important;border:0!important}
  #dashboard .kpis .kpi{min-width:0!important;border:1px solid #e2e7eb!important;border-radius:12px!important;padding:12px!important;height:auto!important;min-height:112px!important}
  #dashboard .kpi strong{font-size:clamp(18px,5vw,24px)!important;line-height:1.2!important;overflow-wrap:anywhere}
  #dashboard .kpi .delta{white-space:normal!important;line-height:1.4}
  .dashboard-priority-copy{min-width:0!important}
  .dashboard-priority-copy b,.dashboard-priority-copy span{white-space:normal!important;overflow-wrap:anywhere}
  #leads .tablewrap,#dashboard .tablewrap{width:100%!important;min-width:0!important;overflow:visible!important}
  #leads .table,#dashboard .table{display:block!important;width:100%!important;min-width:0!important;border:0!important;border-spacing:0!important;overflow:visible!important}
  #leads .table thead,#dashboard .table thead{display:none!important}
  #leads .table tbody,#dashboard .table tbody{display:grid!important;grid-template-columns:minmax(0,1fr)!important;gap:10px!important;width:100%!important}
  #leads .table tbody tr,#dashboard .table tbody tr{
    display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;
    height:auto!important;min-height:0!important;gap:8px 12px!important;
    padding:14px!important;border:1px solid #e2e7eb!important;border-radius:12px!important;background:#fff!important;
  }
  #leads .table tbody tr td,#dashboard .table tbody tr td{
    display:block!important;width:auto!important;min-width:0!important;max-width:100%!important;
    height:auto!important;padding:0!important;border:0!important;white-space:normal!important;overflow:visible!important;overflow-wrap:anywhere;
  }
  #leads .table tbody tr[data-id]{position:relative!important}
  #leads .table tbody tr[data-id] td{grid-column:auto!important;grid-row:auto!important}
  #leads .table tbody tr[data-id] td.desa-lead-identity{grid-column:1/-1!important;grid-row:1!important;padding-right:28px!important}
  #leads .table tbody tr[data-id] td.desa-lead-created{grid-column:1/-1!important;grid-row:2!important;color:#75838b}
  #leads .table tbody tr[data-id] td.desa-lead-source{grid-column:1/-1!important;grid-row:3!important}
  #leads .table tbody tr[data-id] td.desa-lead-status{grid-column:1!important;grid-row:4!important}
  #leads .table tbody tr[data-id] td.desa-lead-score{grid-column:2!important;grid-row:4!important}
  #leads .table tbody tr[data-id] td.desa-lead-budget{grid-column:1/-1!important;grid-row:5!important}
  #leads .table tbody tr[data-id] td.desa-lead-next{grid-column:1/-1!important;grid-row:6!important;border-top:1px solid #edf0f2!important;padding-top:8px!important}
  #leads .table tbody tr[data-id] td.desa-select-cell{grid-column:auto!important;grid-row:auto!important;position:absolute!important;top:14px;right:12px;width:24px!important;min-width:0!important;padding:0!important}
  #dashboard .table tbody tr td:nth-child(2){grid-column:1/-1!important;grid-row:1!important}
  #dashboard .table tbody tr td:nth-child(1){grid-column:1/-1!important;grid-row:2!important;color:#75838b}
  #dashboard .table tbody tr td:nth-child(3){grid-column:1/-1!important;grid-row:3!important}
  #dashboard .table tbody tr td:nth-child(4){grid-column:1!important;grid-row:4!important}
  #dashboard .table tbody tr td:nth-child(5){grid-column:2!important;grid-row:4!important;text-align:right}
  #leads .lead-main,#dashboard .lead-main{min-width:0!important;max-width:100%!important}
  #leads .lead-main>div:last-child,#dashboard .lead-main>div:last-child{min-width:0!important}
  #leads .lead-name,#dashboard .lead-name,#leads .lead-sub,#dashboard .lead-sub{white-space:normal!important;overflow-wrap:anywhere}
  #leads .status,#dashboard .status{display:inline-block;max-width:100%;white-space:normal!important}
  #leads .toolbar select{height:44px!important;min-height:44px!important;line-height:normal!important;padding:8px 10px!important}
  #leads .toolbar .search{height:auto!important;min-height:44px;display:flex!important;align-items:center;gap:8px}
  #leads .toolbar .search input{min-width:0!important;width:100%!important;padding:0!important;border:0!important;box-shadow:none!important;background:transparent!important}
}

/* Confirmed budget is editable without changing the imported form answers. */
.desa-budget-controls{display:flex;gap:6px;align-items:center;margin-top:6px}
.desa-budget-controls input{width:100%;min-width:0;padding:8px;border:1px solid #dce3e6;border-radius:6px;font-size:16px;background:#fff;color:#27332d}
.desa-budget-controls .btn{flex-shrink:0;min-height:40px;padding:8px 10px}
.desa-actual-budget label{font-size:12px;color:#697981}
.desa-actual-budget small{display:block;margin-top:4px;color:#536b60}
@media(max-width:800px){
  .desktop-main{padding-left:12px!important;padding-right:12px!important}
  .view{padding-left:0!important;padding-right:0!important}
  .page-head h2,.dashboard-welcome h1{font-size:24px!important;line-height:1.2!important}
  .page-head,.dashboard-welcome{margin-bottom:12px!important;padding-bottom:12px!important}
  .dashboard-welcome p{font-size:13px!important;margin-top:6px!important}
  #dashboard .kpis{gap:8px!important;margin-bottom:12px!important}
  #dashboard .kpis .kpi{padding:10px!important;min-height:80px!important;border-radius:9px!important}
  #dashboard .kpi>span{font-size:10px!important;line-height:1.3!important}
  #dashboard .kpi .delta{display:none!important}
  #dashboard .panel{padding:12px!important;margin-bottom:10px!important;border-radius:10px!important}
  #dashboard .panelhead{margin-bottom:8px!important;padding-bottom:8px!important;gap:8px!important}
  #dashboard .panelhead h2{font-size:16px!important}
  #dashboard .panelhead button{font-size:12px!important;white-space:nowrap}
  .dashboard-priority-item{padding:10px 0!important}
  .dashboard-priority-copy span{font-size:12px!important}
  #leads .page-head{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px!important}
  #leads .page-head>div:first-child{grid-column:1/-1}
  #leads .page-head p{display:none!important}
  #leads .page-head>.btn{width:100%!important;height:auto!important;min-height:40px!important;padding:8px!important;font-size:12px!important}
  #leads #addLeadBtnTop{grid-column:1/-1}
  #leads #desaArchiveBtn:disabled{display:none!important}
  #leads .lead-overview-stats{gap:6px!important;margin-bottom:10px!important}
  #leads .lead-stat{padding:8px 10px!important;min-height:0!important;border-radius:8px!important}
  #leads .lead-stat span{font-size:10px!important;line-height:1.25!important}
  #leads .lead-stat strong{font-size:21px!important;margin-top:4px!important}
  #leads .lead-count-explainer{display:none!important}
  #leads .toolbar{padding:8px!important;gap:6px!important;margin-bottom:10px!important}
  #leads .toolbar select{font-size:12px!important}
  #leads .table tbody,#dashboard .table tbody{gap:6px!important}
  #leads .table tbody tr,#dashboard .table tbody tr{padding:10px!important;gap:6px 8px!important;border-radius:9px!important}
  #leads .table tbody tr[data-id] td.desa-lead-created{grid-row:2!important;grid-column:1/-1!important;font-size:11px!important}
  #leads .table tbody tr[data-id] td.desa-lead-status{grid-row:3!important;grid-column:1!important}
  #leads .table tbody tr[data-id] td.desa-lead-budget{grid-row:3!important;grid-column:2!important;text-align:right;font-size:12px!important;align-self:center}
  #leads .table tbody tr[data-id] td.desa-lead-next{grid-row:4!important;padding-top:5px!important;font-size:12px!important}
  #leads .table tbody tr[data-id] td.desa-lead-source,#leads .table tbody tr[data-id] td.desa-lead-score{display:none!important}
  #leads .lead-sub,#dashboard .lead-sub,#leads .lead-created-sub,#leads .next-action small{display:none!important}
  #leads .lead-name,#dashboard .lead-name{font-size:14px!important;line-height:1.3!important}
  #leads .leadavatar,#dashboard .leadavatar{width:32px!important;height:32px!important;min-width:32px!important;font-size:11px!important}
  #leads .table tbody tr[data-id] td.desa-select-cell{top:10px!important;right:10px!important}
  #dashboard .table tbody tr td:nth-child(1){grid-column:1!important;grid-row:2!important;font-size:11px!important;align-self:center}
  #dashboard .table tbody tr td:nth-child(3){grid-column:2!important;grid-row:2!important;text-align:right}
  #dashboard .table tbody tr td:nth-child(4),#dashboard .table tbody tr td:nth-child(5){display:none!important}
  .lead-dossier-overlay .lead-dossier-drawer #detail .desa-investor-summary{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .lead-dossier-overlay .lead-dossier-drawer #detail .desa-actual-budget{grid-column:1/-1!important;padding:10px!important}
  .lead-dossier-overlay .lead-dossier-drawer #detail .desa-summary-field{padding:8px 10px!important}
  #properties .property-grid{gap:10px!important}
  #properties .property-img{height:150px!important;min-height:0!important}
  #properties .property-body{padding:12px!important}
  #properties .property-description{min-height:0!important;margin:6px 0 8px!important;font-size:12px!important}
  #properties .property-facts div{padding:6px!important}
  #properties .property-price{margin-bottom:8px!important}
}
@media(max-width:800px){
  #leads .page-head{padding-bottom:0!important}
  #leads .lead-overview-stats{margin-top:12px!important}
  #leads .toolbar .search{min-height:44px!important;height:44px!important;padding:8px!important}
  #leads .table tbody tr[data-id] td{line-height:1.35!important}
  #leads .table tbody tr[data-id] .lead-created-main{font-size:11px!important}
  #leads .table tbody tr[data-id] .next-action{font-size:12px!important}
}
@media(max-width:800px){
  #properties .toolbar{padding:8px!important;gap:6px!important}
  #properties .toolbar select{height:44px!important;min-height:44px!important;line-height:normal!important;padding:8px 10px!important;font-size:12px!important}
  #properties .toolbar .search{display:flex!important;align-items:center;height:44px!important;padding:8px!important}
  #properties .toolbar .search input{min-width:0!important;width:100%!important;padding:0!important;border:0!important;background:transparent!important}
  #properties .property{grid-template-columns:86px minmax(0,1fr)!important}
  #properties .property-title-row{display:block!important}
  #properties .property-title-row b{font-size:15px!important}
  #properties .property-match-count{display:inline-block;margin-top:5px;font-size:10px!important;padding:3px 6px!important}
  #properties .property-description{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
  #properties .property-facts span{font-size:9px!important}
  #properties .property-facts strong{font-size:11px!important}
  #properties .property-card-actions button{min-height:40px!important;padding:6px!important;font-size:11px!important}
}
